{$MODE OBJFPC} { -*- text -*- } program tests; type generic TFoo = class type TBar = class function Baz(): T; end; end; function TFoo.TBar.Baz(): T; begin Result := nil; end; begin end.