mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-07 04:28:00 +02:00

+ 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 -
43 lines
674 B
ObjectPascal
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.
|