mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 15:28:08 +02:00
36 lines
507 B
ObjectPascal
36 lines
507 B
ObjectPascal
{ %NORUN }
|
|
|
|
program tw30626;
|
|
|
|
{$mode objfpc}
|
|
|
|
type
|
|
generic IBase<T> = interface(IUnknown)
|
|
end;
|
|
|
|
generic TBase<T> = class(TInterfacedObject, specialize IBase<T>)
|
|
public
|
|
function Test: specialize IBase<T>;
|
|
end;
|
|
|
|
generic TDerived<T> = class(specialize TBase<T>)
|
|
|
|
end;
|
|
|
|
function TBase.Test: specialize IBase<T>;
|
|
begin
|
|
result := (specialize TDerived<T>).Create;
|
|
end;
|
|
|
|
type
|
|
TIntDerived = specialize TDerived<Integer>;
|
|
|
|
var
|
|
t: TIntDerived;
|
|
|
|
begin
|
|
t := TIntDerived.Create;
|
|
t.Test;
|
|
end.
|
|
|