From 49a9f4c1ea02533dbb14633d359d609fd0169ee9 Mon Sep 17 00:00:00 2001 From: svenbarth Date: Fri, 6 Jun 2014 15:19:45 +0000 Subject: [PATCH] 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 - --- .gitattributes | 1 + compiler/pdecobj.pas | 4 ++-- tests/webtbs/tw26123.pp | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 tests/webtbs/tw26123.pp diff --git a/.gitattributes b/.gitattributes index 0e12e163cd..eeab6334d2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -13938,6 +13938,7 @@ tests/webtbs/tw25956.pp svneol=native#text/pascal tests/webtbs/tw25959.pp svneol=native#text/pascal tests/webtbs/tw2602.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/tw26180.pp svneol=native#text/pascal tests/webtbs/tw2620.pp svneol=native#text/plain diff --git a/compiler/pdecobj.pas b/compiler/pdecobj.pas index a546d25ea7..3e8c21cffb 100644 --- a/compiler/pdecobj.pas +++ b/compiler/pdecobj.pas @@ -1397,9 +1397,9 @@ implementation { usage of specialized type inside its generic template } if assigned(genericdef) then - current_specializedef:=current_structdef + current_specializedef:=current_structdef; { reject declaration of generic class inside generic class } - else if assigned(genericlist) then + if assigned(genericlist) then current_genericdef:=current_structdef; { nested types of specializations are specializations as well } diff --git a/tests/webtbs/tw26123.pp b/tests/webtbs/tw26123.pp new file mode 100644 index 0000000000..1ef7babac0 --- /dev/null +++ b/tests/webtbs/tw26123.pp @@ -0,0 +1,25 @@ +{ %NORUN } + +program tw26123; + +{$mode objfpc} + +type + generic TNode = class // anything can go in this class + end; + + generic TLinkedList = class + type + specialized_TNode = specialize TNode; + public + node : specialized_TNode; + end; + + + generic TExtendedLinkedList = class (specialize TLinkedList) + public + last_node : specialized_TNode; + end; + +begin +end.