소스 검색

compiler: fix search of outer class type inside inner type declarations (bug #0017945)

git-svn-id: trunk@16352 -
paul 14 년 전
부모
커밋
a8deeaa168
3개의 변경된 파일32개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 0
      .gitattributes
  2. 17 10
      compiler/ptype.pas
  3. 14 0
      tests/webtbs/tw17945.pp

+ 1 - 0
.gitattributes

@@ -10751,6 +10751,7 @@ tests/webtbs/tw17907/unit2/unit0002.pas svneol=native#text/plain
 tests/webtbs/tw1792.pp svneol=native#text/plain
 tests/webtbs/tw17928.pp svneol=native#text/plain
 tests/webtbs/tw1792a.pp svneol=native#text/plain
+tests/webtbs/tw17945.pp svneol=native#text/pascal
 tests/webtbs/tw17950.pp svneol=native#text/pascal
 tests/webtbs/tw1798.pp svneol=native#text/plain
 tests/webtbs/tw1820.pp svneol=native#text/plain

+ 17 - 10
compiler/ptype.pas

@@ -546,23 +546,30 @@ implementation
            lv,hv   : TConstExprInt;
            old_block_type : tblock_type;
            dospecialize : boolean;
+           objdef: TDef;
         begin
            old_block_type:=block_type;
            dospecialize:=false;
            { use of current parsed object:
               - classes can be used also in classes
               - objects can be parameters }
-           if (token=_ID) and
-              assigned(current_objectdef) and
-              (current_objectdef.objname^=pattern) and
-              (
-               (testcurobject=2) or
-               is_class_or_interface_or_objc(current_objectdef)
-              )then
+           if (token=_ID) then
              begin
-               consume(_ID);
-               def:=current_objectdef;
-               exit;
+               objdef:=current_objectdef;
+               while Assigned(objdef) and (objdef.typ=objectdef) do
+                 begin
+                   if (tobjectdef(objdef).objname^=pattern) and
+                      (
+                        (testcurobject=2) or
+                        is_class_or_interface_or_objc(objdef)
+                      ) then
+                      begin
+                        consume(_ID);
+                        def:=objdef;
+                        exit;
+                      end;
+                   objdef:=tobjectdef(tobjectdef(objdef).owner.defowner);
+                 end;
              end;
            { Generate a specialization? }
            if try_to_consume(_SPECIALIZE) then

+ 14 - 0
tests/webtbs/tw17945.pp

@@ -0,0 +1,14 @@
+program tw17945;
+{$mode delphi}
+type
+  TFoo = class
+  public
+    type
+      TEnumerator = object
+      private
+        FFoo: TFoo; //Was error: Illegal expression
+      end;
+  end;
+
+begin
+end.