Browse Source

compiler: push nested class hierarchy for parsing nested procedures arguments and results (mantis #0020690, mantis #0020038)

git-svn-id: trunk@19641 -
paul 13 years ago
parent
commit
7f7c665e64
3 changed files with 41 additions and 2 deletions
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/pdecsub.pas
  3. 38 0
      tests/webtbs/tw20690.pp

+ 1 - 0
.gitattributes

@@ -11895,6 +11895,7 @@ tests/webtbs/tw20594.pp svneol=native#text/pascal
 tests/webtbs/tw20638.pp svneol=native#text/pascal
 tests/webtbs/tw2065.pp svneol=native#text/plain
 tests/webtbs/tw2069.pp svneol=native#text/plain
+tests/webtbs/tw20690.pp svneol=native#text/pascal
 tests/webtbs/tw2072.pp svneol=native#text/plain
 tests/webtbs/tw2109.pp svneol=native#text/plain
 tests/webtbs/tw2110.pp svneol=native#text/plain

+ 2 - 2
compiler/pdecsub.pas

@@ -1222,7 +1222,7 @@ implementation
             { Add ObjectSymtable to be able to find nested type definitions }
             popclass:=0;
             if assigned(pd.struct) and
-               (pd.parast.symtablelevel=normal_function_level) and
+               (pd.parast.symtablelevel>=normal_function_level) and
                not(symtablestack.top.symtabletype in [ObjectSymtable,recordsymtable]) then
               begin
                 popclass:=push_nested_hierarchy(pd.struct);
@@ -1276,7 +1276,7 @@ implementation
             { Add ObjectSymtable to be able to find generic type definitions }
             popclass:=0;
             if assigned(pd.struct) and
-               (pd.parast.symtablelevel=normal_function_level) and
+               (pd.parast.symtablelevel>=normal_function_level) and
                not (symtablestack.top.symtabletype in [ObjectSymtable,recordsymtable]) then
               begin
                 popclass:=push_nested_hierarchy(pd.struct);

+ 38 - 0
tests/webtbs/tw20690.pp

@@ -0,0 +1,38 @@
+{%norun}
+program tw20690;
+{$MODE delphi}
+
+type
+  TTestClass = class
+  strict private
+    type TLocalInteger = Integer;
+  public
+    procedure WriteInteger(value: TLocalInteger);
+  end;
+
+procedure TTestClass.WriteInteger(value: TLocalInteger);
+
+  procedure _InacessibleInDeclaration1(i: TLocalInteger); begin end;
+    { The compiler will report that TLocalInteger is not found }
+
+  procedure _InacessibleInDeclaration2(i: TTestClass.TLocalInteger); begin end;
+    { The compiler will report the same error even if the fully qualified type
+      identifier is used }
+
+  function _InacessibleInDeclaration3(i: TLocalInteger):TLocalInteger; begin end;
+
+  procedure _AccessibleInImplementation;
+  begin
+    Writeln(SizeOf(TLocalInteger));  { But this will work }
+  end;
+
+begin
+  Writeln(value);
+end;
+
+begin
+  with TTestClass.Create do begin
+    WriteInteger(123);
+    Free;
+  end;
+end.