program tgeneric107; {$Mode ObjFpc} type generic G = class var X: T; // EXPECTED: gets compiled // ACTUAL: 'Error: Generics without specialization cannot be used as a type for a variable' class var F: function(const X: T) : specialize G of object; function Foo(const aX: T): specialize G; end; function G.Foo(const aX: T): specialize G; begin result := specialize G.Create; result.X := aX end; begin specialize G.F := @specialize G.Create.Foo; if specialize G.F(42).X <> 42 then halt(1); end.