Browse Source

Mantis #25043 was fixed by partial specializations addition in revision 27861

+ added test

git-svn-id: trunk@27879 -
svenbarth 11 years ago
parent
commit
94f47443f0
2 changed files with 80 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 79 0
      tests/webtbs/tw25043.pp

+ 1 - 0
.gitattributes

@@ -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 - 0
tests/webtbs/tw25043.pp

@@ -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.