Frage

I get an internal compile error with Delphi XE3 Update 2 when I execute the following code:

unit Unit1;

interface

type
  IHasValueR<T> = interface
    function GetValue: T;
  end;

  IHasValueRw<T> = interface(IHasValueR<T>)
    procedure SetValue(NewValue: T);
  end;
  TDummy = class(TInterfacedObject)

  end;

  TRefObj = class(TInterfacedObject, IHasValueR<Boolean>, IHasValueRw<Boolean>)
  strict private
    Value: Boolean;
  public
    constructor Create(Init_: Boolean);
    function GetValue: Boolean;
    procedure SetValue(NewValue: Boolean);
  end;

  TValueProviderFct<T, V> = reference to function(Input: T): V;

  TBar<T; V: IHasValueRw<Boolean>> = class
  strict private
    FValueProviderFct: TValueProviderFct<T, V>;
  public
    constructor Create(ValueProviderFct_: TValueProviderFct<T, V>);
    function GetValue(Input: T): Boolean;
  end;

procedure TestIt();

implementation

procedure TestIt();
var
  Foo: TRefObj;
  Bar: TBar<TRefObj, IHasValueRw<Boolean>>;
begin
  Foo := TRefObj.Create(true);

  Bar := TBar<TRefObj, IHasValueRw<Boolean>>.Create(
    function (Input: TRefObj): IHasValueRw<Boolean>
    begin
      Result := Input;
    end
  );
  Bar.GetValue(Foo);
end;

{ TSetupDefinitionItemBoolean }

constructor TRefObj.Create(Init_: Boolean);
begin
  Value := Init_;
end;

function TRefObj.GetValue: Boolean;
begin
  Result := Value;
end;

procedure TRefObj.SetValue(NewValue: Boolean);
begin
  Value := NewValue;
end;

{ TBar<T, V> }

constructor TBar<T, V>.Create(ValueProviderFct_: TValueProviderFct<T, V>);
begin
  FValueProviderFct := ValueProviderFct_;
end;

function TBar<T, V>.GetValue;
begin
  Result := FValueProviderFct(Input).GetValue;
end;

end.

error-message:

[dcc32 Fatal Error] Unit1.pas(83): F2084 Internal Error: C13823

The solution is simply to add GUIDs to the interfaces.

Can anyone verify this? Is it maybe already fixed in a newer Delphi version? Where can we file a bugreport?

War es hilfreich?

Lösung

Can anyone verify this? Is it maybe already fixed in a newer Delphi version?

For the record:
This is fixed in Delphi XE4.

It also compiles just fine in XE2, so it seems to be specific to your version.

Where can we file a bugreport?

http://qc.embarcadero.com/wc/qcmain.aspx

Andere Tipps

Misses GUID, in the interface, key CTRL + SHIFT + G, as below :

  IHasValueR<T> = interface
['{45609E3B-D9A6-40FB-B9E8-86E3FE0D20EF}']
    function GetValue: T;
  end;
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top