Sfoglia il codice sorgente

compiler: fix property access from a nested routine of the static class method and extend a test

git-svn-id: trunk@25280 -
paul 12 anni fa
parent
commit
4b76782691
2 ha cambiato i file con 12 aggiunte e 8 eliminazioni
  1. 4 6
      compiler/pexpr.pas
  2. 8 2
      tests/webtbs/tw24865.pp

+ 4 - 6
compiler/pexpr.pas

@@ -2671,12 +2671,10 @@ implementation
                       begin
                         if (srsymtable.symtabletype in [ObjectSymtable,recordsymtable]) then
                           { if we are accessing a owner procsym from the nested }
-                          { class we need to call it as a class member          }
-                          if assigned(current_structdef) and (current_structdef<>hdef) and is_owned_by(current_structdef,hdef) then
-                            p1:=cloadvmtaddrnode.create(ctypenode.create(hdef))
-                          else
-                          if assigned(current_procinfo) and current_procinfo.procdef.no_self_node then
-                          { no self node in static class methods }
+                          { class or from a static class method we need to call }
+                          { it as a class member                                }
+                          if (assigned(current_structdef) and (current_structdef<>hdef) and is_owned_by(current_structdef,hdef)) or
+                             (assigned(current_procinfo) and current_procinfo.get_normal_proc.procdef.no_self_node) then
                             p1:=cloadvmtaddrnode.create(ctypenode.create(hdef))
                           else
                             p1:=load_self_node;

+ 8 - 2
tests/webtbs/tw24865.pp

@@ -5,8 +5,11 @@ program tw24865;
 
 type
   TTest = class
+  public
+    class var fc3: integer;
     class procedure c1();
     class procedure c2(); static;
+    class property c3: integer read fc3 write fc3;
   end;
 
 class procedure TTest.c1;
@@ -14,9 +17,13 @@ begin
 end;
 
 class procedure TTest.c2;
-  procedure nested;
+
+  function nested: integer;
   begin
     c1;
+    fc3 := 1;
+    c3 := 2;
+    result := c3;
   end;
 
 begin
@@ -24,4 +31,3 @@ end;
 
 begin
 end.
-