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

- multiple symbols with a similar name - hint directives - inline specializations git-svn-id: branches/svenbarth/generics@17542 -
40 lines
651 B
ObjectPascal
40 lines
651 B
ObjectPascal
{ this tests that simple inline specializations work }
|
|
program tgeneric51;
|
|
|
|
{$ifdef fpc}
|
|
{$mode delphi}
|
|
{$endif}
|
|
{$apptype console}
|
|
|
|
type
|
|
TTest<T> = class
|
|
function Test(a: T): T;
|
|
class function ClassTest(a: T): T;
|
|
end;
|
|
|
|
function TTest<T>.Test(a: T): T;
|
|
begin
|
|
Result := a;
|
|
end;
|
|
|
|
class function TTest<T>.ClassTest(a: T): T;
|
|
begin
|
|
Result := a;
|
|
end;
|
|
|
|
var
|
|
t: TTest<Integer>;
|
|
res: Integer;
|
|
begin
|
|
t := TTest<Integer>.Create;
|
|
res := t.Test(42);
|
|
Writeln('t.Test: ', res);
|
|
if res <> 42 then
|
|
Halt(1);
|
|
res := TTest<Integer>.ClassTest(42);
|
|
Writeln('t.ClassTest: ', res);
|
|
if res <> 42 then
|
|
Halt(2);
|
|
Writeln('ok');
|
|
end.
|