fpc/tests/webtbs/tw31120.pp
svenbarth d34acf3bc7 * fix for Mantis : check current_genericdef only if the current_procinfo isn't used
+ added test

Note: the test is added to webtbs although it's right now still failing, cause I'll remove the restriction for nested procedures since the compiler now supports them correctly. Due to the way we handle generics we don't have problems with them unlike Delphi.

git-svn-id: trunk@35147 -
2016-12-17 21:20:44 +00:00

43 lines
674 B
ObjectPascal

{ %NORUN }
program tw31120;
{$mode objfpc}
type
TTest = class
generic class procedure PrintDefault<T>();
end;
generic Function GetDefault<T>(): T;
Begin
result := default(T);
End;
generic Procedure PrintDefault<T>();
procedure print();
begin
writeln(specialize GetDefault<T>())
end;
Begin
print()
End;
generic class procedure TTest.PrintDefault<T>();
procedure print();
begin
writeln(specialize GetDefault<T>())
end;
begin
print()
end;
Begin
specialize PrintDefault<LongInt>();
specialize PrintDefault<String>();
TTest.specialize PrintDefault<Boolean>();
TTest.specialize PrintDefault<Char>();
End.