mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 05:59:28 +02:00
Mantis #25043 was fixed by partial specializations addition in revision 27861
+ added test git-svn-id: trunk@27879 -
This commit is contained in:
parent
6f962e817a
commit
94f47443f0
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -13887,6 +13887,7 @@ tests/webtbs/tw25004.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw2503.pp svneol=native#text/plain
|
||||
tests/webtbs/tw25030.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw2504.pp svneol=native#text/plain
|
||||
tests/webtbs/tw25043.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25054a.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25054b.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25059.pp svneol=native#text/pascal
|
||||
|
79
tests/webtbs/tw25043.pp
Normal file
79
tests/webtbs/tw25043.pp
Normal file
@ -0,0 +1,79 @@
|
||||
program tw25043;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{$MODE DELPHI}
|
||||
{$ENDIF}
|
||||
|
||||
const
|
||||
TestValue = 30061978;
|
||||
|
||||
type
|
||||
TDescendant = class(TObject)
|
||||
public
|
||||
function GetValue(): Integer;
|
||||
end;
|
||||
|
||||
TCollection<E: class> = class(TObject)
|
||||
protected
|
||||
Value: E;
|
||||
|
||||
function GetElements(Index: Integer): E;
|
||||
|
||||
public
|
||||
property Element: E read Value;
|
||||
property Elements[Index: Integer]: E read GetElements; default;
|
||||
end;
|
||||
|
||||
TDescendantCollection<E: TDescendant> = class(TCollection<E>)
|
||||
public
|
||||
procedure TestValues();
|
||||
end;
|
||||
|
||||
{ TDescendant }
|
||||
|
||||
function TDescendant.GetValue(): Integer;
|
||||
begin
|
||||
Result := TestValue;
|
||||
end;
|
||||
|
||||
{ TDescendantCollection<E> }
|
||||
|
||||
procedure TDescendantCollection<E>.TestValues();
|
||||
begin
|
||||
if Value.GetValue() <> TestValue then
|
||||
Halt(1);
|
||||
|
||||
if Element.GetValue() <> TestValue then
|
||||
Halt(1);
|
||||
|
||||
if GetElements(0).GetValue() <> TestValue then
|
||||
Halt(1);
|
||||
|
||||
if Elements[0].GetValue() <> TestValue then
|
||||
Halt(1);
|
||||
|
||||
if Self[0].GetValue() <> TestValue then
|
||||
Halt(1);
|
||||
end;
|
||||
|
||||
{ TCollection<E> }
|
||||
|
||||
function TCollection<E>.GetElements(Index: Integer): E;
|
||||
begin
|
||||
Result := Value;
|
||||
end;
|
||||
|
||||
var
|
||||
Collection: TDescendantCollection<TDescendant>;
|
||||
Descendant: TDescendant;
|
||||
|
||||
begin
|
||||
Descendant := TDescendant.Create();
|
||||
|
||||
Collection := TDescendantCollection<TDescendant>.Create();
|
||||
Collection.Value := Descendant;
|
||||
Collection.TestValues();
|
||||
Collection.Free();
|
||||
|
||||
Descendant.Free();
|
||||
end.
|
Loading…
Reference in New Issue
Block a user