type
TForm72 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TTestForm = class(TForm)
public
constructor CreateTest(AOwner: TComponent); virtual;
end;
TTestForm1 = class(TTestForm)
public
constructor CreateTest(AOwner: TComponent); override;
end;
TTest<T: TTestForm, constructor> = class(TObject)
public
class procedure Test;
end;
var
Form72: TForm72;
implementation
{$R *.dfm}
procedure TForm72.FormCreate(Sender: TObject);
begin
TTest<TTestForm1>.Test;
end;
{ TTest<T> }
class procedure TTest<T>.Test;
var
F: T;
begin
F := T.CreateTest(Application);
Form72.Caption := F.Name;
end;
{ TTestForm }
constructor TTestForm.CreateTest(AOwner: TComponent);
begin
inherited Create(AOwner);
end;
{ TTestForm1 }
constructor TTestForm1.CreateTest(AOwner: TComponent);
begin
inherited;
Caption := 'Bang';
end;
end.
此代码在 XE2 中编译,但在 XE3 中出现“[dcc32 Error] Unit71.pas(55): E2010 Incompatible types: 'T' and 'procedure, untyped pointer or untyped parameter'”失败。我做错了什么,或者编译器做错了什么?