pascalabcnet/TestSuite/lambdas_generics8.pas

26 lines
369 B
ObjectPascal
Raw Permalink Normal View History

2020-12-28 20:16:22 +03:00
type
t0 = abstract class
end;
t2 = class(t0)
end;
t1<T> = class
where T: t0, constructor;
public obj: T;
procedure p1;
begin
var p: Action0 := ()->
begin
obj := new T;
end;
p();
end;
end;
begin
var o := new t1<t2>;
o.p1;
assert((o.obj <> nil) and (o.obj.GetType = typeof(t2)));
end.