瀏覽代碼

Fix for Mantis #26123.

pdecobj.pas, object_dec:
  * Always check for genericdef and genericlist and not genericdef and ifnot then genericlist.

+ added test

git-svn-id: trunk@27877 -
svenbarth 11 年之前
父節點
當前提交
49a9f4c1ea
共有 3 個文件被更改,包括 28 次插入2 次删除
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/pdecobj.pas
  3. 25 0
      tests/webtbs/tw26123.pp

+ 1 - 0
.gitattributes

@@ -13938,6 +13938,7 @@ tests/webtbs/tw25956.pp svneol=native#text/pascal
 tests/webtbs/tw25959.pp svneol=native#text/pascal
 tests/webtbs/tw25959.pp svneol=native#text/pascal
 tests/webtbs/tw2602.pp svneol=native#text/plain
 tests/webtbs/tw2602.pp svneol=native#text/plain
 tests/webtbs/tw2607.pp svneol=native#text/plain
 tests/webtbs/tw2607.pp svneol=native#text/plain
+tests/webtbs/tw26123.pp svneol=native#text/pascal
 tests/webtbs/tw26162.pp svneol=native#text/pascal
 tests/webtbs/tw26162.pp svneol=native#text/pascal
 tests/webtbs/tw26180.pp svneol=native#text/pascal
 tests/webtbs/tw26180.pp svneol=native#text/pascal
 tests/webtbs/tw2620.pp svneol=native#text/plain
 tests/webtbs/tw2620.pp svneol=native#text/plain

+ 2 - 2
compiler/pdecobj.pas

@@ -1397,9 +1397,9 @@ implementation
 
 
         { usage of specialized type inside its generic template }
         { usage of specialized type inside its generic template }
         if assigned(genericdef) then
         if assigned(genericdef) then
-          current_specializedef:=current_structdef
+          current_specializedef:=current_structdef;
         { reject declaration of generic class inside generic class }
         { reject declaration of generic class inside generic class }
-        else if assigned(genericlist) then
+        if assigned(genericlist) then
           current_genericdef:=current_structdef;
           current_genericdef:=current_structdef;
 
 
         { nested types of specializations are specializations as well }
         { nested types of specializations are specializations as well }

+ 25 - 0
tests/webtbs/tw26123.pp

@@ -0,0 +1,25 @@
+{ %NORUN }
+
+program tw26123;
+
+{$mode objfpc}
+
+type
+    generic TNode<data_type> = class // anything can go in this class
+    end;
+
+    generic TLinkedList<data_type> = class
+      type
+          specialized_TNode = specialize TNode<data_type>;
+      public
+        node : specialized_TNode;
+    end;
+
+
+    generic TExtendedLinkedList<data_type> = class (specialize TLinkedList<data_type>)
+      public
+        last_node : specialized_TNode;
+    end;
+
+begin
+end.