mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 10:38:14 +02:00
23 lines
440 B
ObjectPascal
23 lines
440 B
ObjectPascal
{ test syntax of a generic class function in mode objfpc }
|
|
|
|
program tgenfunc3;
|
|
|
|
{$mode objfpc}
|
|
|
|
type
|
|
TTest = class
|
|
generic class function Add<T>(aLeft, aRight: T): T;
|
|
end;
|
|
|
|
generic class function TTest.Add<T>(aLeft, aRight: T): T;
|
|
begin
|
|
Result := aLeft + aRight;
|
|
end;
|
|
|
|
begin
|
|
if TTest.specialize Add<LongInt>(2, 3) <> 5 then
|
|
Halt(1);
|
|
if TTest.specialize Add<String>('Hello', 'World') <> 'HelloWorld' then
|
|
Halt(2);
|
|
end.
|