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

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