瀏覽代碼

compiler: fix internal class symbol search for method arguments

git-svn-id: trunk@14610 -
paul 15 年之前
父節點
當前提交
fd6e2cc86e
共有 3 個文件被更改,包括 30 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 6 0
      compiler/pdecsub.pas
  3. 23 0
      tests/test/tclass12c.pp

+ 1 - 0
.gitattributes

@@ -8894,6 +8894,7 @@ tests/test/tclass11a.pp svneol=native#text/pascal
 tests/test/tclass11b.pp svneol=native#text/pascal
 tests/test/tclass12a.pp svneol=native#text/pascal
 tests/test/tclass12b.pp svneol=native#text/pascal
+tests/test/tclass12c.pp svneol=native#text/pascal
 tests/test/tclass2.pp svneol=native#text/plain
 tests/test/tclass3.pp svneol=native#text/plain
 tests/test/tclass4.pp svneol=native#text/plain

+ 6 - 0
compiler/pdecsub.pas

@@ -702,6 +702,7 @@ implementation
         popclass : boolean;
         ImplIntf : TImplementedInterface;
         old_parse_generic : boolean;
+        old_current_objectdef: tobjectdef;
       begin
         { Save the position where this procedure really starts }
         procstartfilepos:=current_tokenpos;
@@ -962,6 +963,8 @@ implementation
                (symtablestack.top.symtabletype<>ObjectSymtable) then
               begin
                 symtablestack.push(pd._class.symtable);
+                old_current_objectdef:=current_objectdef;
+                current_objectdef:=pd._class;
                 popclass:=true;
               end;
             { Add parameter symtable }
@@ -971,7 +974,10 @@ implementation
             if pd.parast.symtabletype<>staticsymtable then
               symtablestack.pop(pd.parast);
             if popclass then
+            begin
+              current_objectdef:=old_current_objectdef;
               symtablestack.pop(pd._class.symtable);
+            end;
           end;
 
         parse_generic:=old_parse_generic;

+ 23 - 0
tests/test/tclass12c.pp

@@ -0,0 +1,23 @@
+program tclass12c;
+{$ifdef fpc}
+  {$mode delphi}
+{$endif}
+{$apptype console}
+
+type
+  TSomeClass = class
+  strict private
+    const
+      PrivateConst = 1;
+    type
+      PrivateType = type Integer;
+  public
+    procedure DoSomething(Value: PrivateType = PrivateConst);
+  end;
+
+  procedure TSomeClass.DoSomething(Value: PrivateType = PrivateConst);
+  begin
+  end;
+
+begin
+end.