mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-23 07:49:40 +02:00
41 lines
609 B
ObjectPascal
41 lines
609 B
ObjectPascal
{ %FAIL }
|
|
|
|
program tw35981;
|
|
|
|
{$mode Delphi}
|
|
|
|
uses Classes;
|
|
|
|
type
|
|
TFoo<T: TPersistent> = class(TPersistent)
|
|
public
|
|
C: T;
|
|
constructor Create;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
constructor TFoo<T>.Create;
|
|
begin
|
|
inherited Create;
|
|
C := T.Create;
|
|
end;
|
|
|
|
destructor TFoo<T>.Destroy;
|
|
begin
|
|
C.Free;
|
|
inherited Destroy;
|
|
end;
|
|
|
|
// note the *working* specialize here, in {$mode Delphi} !!!
|
|
function Test<T: TPersistent>: specialize TFoo<T>;
|
|
begin
|
|
Result := TFoo<T>.Create;
|
|
end;
|
|
|
|
begin
|
|
with Test<TStrings> do begin
|
|
WriteLn(C.ClassName);
|
|
Free;
|
|
end;
|
|
end.
|