2
0
Эх сурвалжийг харах

* allow accessing strict protected symbols from the extended struct inside
helpers (mantis #21811)

git-svn-id: trunk@22569 -

Jonas Maebe 12 жил өмнө
parent
commit
42f6caa0d1

+ 1 - 0
.gitattributes

@@ -12851,6 +12851,7 @@ tests/webtbs/tw2176.pp svneol=native#text/plain
 tests/webtbs/tw2177.pp svneol=native#text/plain
 tests/webtbs/tw2177.pp svneol=native#text/plain
 tests/webtbs/tw2178.pp svneol=native#text/plain
 tests/webtbs/tw2178.pp svneol=native#text/plain
 tests/webtbs/tw21808.pp svneol=native#text/plain
 tests/webtbs/tw21808.pp svneol=native#text/plain
+tests/webtbs/tw21811.pp svneol=native#text/plain
 tests/webtbs/tw2185.pp svneol=native#text/plain
 tests/webtbs/tw2185.pp svneol=native#text/plain
 tests/webtbs/tw2186.pp svneol=native#text/plain
 tests/webtbs/tw2186.pp svneol=native#text/plain
 tests/webtbs/tw2187.pp svneol=native#text/plain
 tests/webtbs/tw2187.pp svneol=native#text/plain

+ 6 - 0
compiler/symtable.pas

@@ -2177,6 +2177,12 @@ implementation
                          { helpers can access strict protected symbols }
                          { helpers can access strict protected symbols }
                          is_objectpascal_helper(contextobjdef) and
                          is_objectpascal_helper(contextobjdef) and
                          tobjectdef(contextobjdef).extendeddef.is_related(symownerdef)
                          tobjectdef(contextobjdef).extendeddef.is_related(symownerdef)
+                       ) or
+                       (
+                         { same as above, but from context of call node inside
+                           helper method }
+                         is_objectpascal_helper(current_structdef) and
+                         tobjectdef(current_structdef).extendeddef.is_related(symownerdef)
                        );
                        );
             end;
             end;
           vis_protected :
           vis_protected :

+ 35 - 0
tests/webtbs/tw21811.pp

@@ -0,0 +1,35 @@
+{$mode objfpc}
+type
+  TC1 = class
+  strict protected
+    procedure P;
+  end;
+
+  TH1 = class helper for TC1
+  public
+    procedure Q;
+  end;
+
+var
+  b: boolean;
+
+procedure TC1.P;
+  begin
+    b:=true;
+  end;
+
+procedure TH1.Q;
+  begin
+    inherited P;
+  end;
+
+var
+  c: tc1;
+begin
+  b:=false;
+  c:=tc1.create;
+  c.q;
+  c.free;
+  if not b then
+    halt(1);
+end.