From fd6e2cc86e4d3464c2e48f2256cd0d0b006d876e Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 11 Jan 2010 09:55:53 +0000 Subject: [PATCH] compiler: fix internal class symbol search for method arguments git-svn-id: trunk@14610 - --- .gitattributes | 1 + compiler/pdecsub.pas | 6 ++++++ tests/test/tclass12c.pp | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 tests/test/tclass12c.pp diff --git a/.gitattributes b/.gitattributes index e07808602c..cc52076678 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/pdecsub.pas b/compiler/pdecsub.pas index e20f1f6da1..aafa49f37f 100644 --- a/compiler/pdecsub.pas +++ b/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; diff --git a/tests/test/tclass12c.pp b/tests/test/tclass12c.pp new file mode 100644 index 0000000000..00cca16ed7 --- /dev/null +++ b/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.