mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-29 10:39:37 +02:00
+ test procedure override in generic classes
git-svn-id: trunk@5425 -
This commit is contained in:
parent
a2c03515e5
commit
da1fcf6e34
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -6475,6 +6475,7 @@ tests/test/tfpuover.pp svneol=native#text/plain
|
||||
tests/test/tgeneric1.pp svneol=native#text/plain
|
||||
tests/test/tgeneric10.pp svneol=native#text/plain
|
||||
tests/test/tgeneric11.pp svneol=native#text/plain
|
||||
tests/test/tgeneric12.pp svneol=native#text/plain
|
||||
tests/test/tgeneric2.pp svneol=native#text/plain
|
||||
tests/test/tgeneric3.pp svneol=native#text/plain
|
||||
tests/test/tgeneric4.pp svneol=native#text/plain
|
||||
|
45
tests/test/tgeneric12.pp
Normal file
45
tests/test/tgeneric12.pp
Normal file
@ -0,0 +1,45 @@
|
||||
{$mode objfpc}
|
||||
|
||||
type
|
||||
TSList = class(TObject)
|
||||
procedure Test; virtual;
|
||||
end;
|
||||
|
||||
generic TList<_T> = class(TSList)
|
||||
data : _T;
|
||||
procedure Add(item: _T);
|
||||
procedure Test; override;
|
||||
end;
|
||||
|
||||
TListCompareFunc = function(Item1, Item2: Integer): Integer;
|
||||
|
||||
procedure TSList.Test;
|
||||
begin
|
||||
writeln('should call TList!');
|
||||
halt(1);
|
||||
end;
|
||||
|
||||
procedure TList.Add(item: _T);
|
||||
begin
|
||||
data:=item;
|
||||
end;
|
||||
|
||||
procedure TList.Test;
|
||||
begin
|
||||
if data <> 10 then
|
||||
halt(1);
|
||||
writeln('ok');
|
||||
end;
|
||||
|
||||
type
|
||||
TMyIntList = specialize TList<Integer>;
|
||||
|
||||
var
|
||||
ilist: TMyIntList;
|
||||
list: TSList;
|
||||
begin
|
||||
ilist := TMyIntList.Create;
|
||||
list := ilist;
|
||||
ilist.add(10);
|
||||
list.test;
|
||||
end.
|
Loading…
Reference in New Issue
Block a user