Browse Source

Now fix the problem from the last commit correctly:
* symtable.pas, search_last_objectpascal_helper: initialize "odef" at the beginning and move the check at the end back to after the loop
* pstatmnt.pas, _with_statement: the checks for success aren't needed anymore as "(parent)helperdef" will be Nil in case "search_last_objectpascal_helper" doesn't find anything as it should have been from the beginning...

git-svn-id: branches/svenbarth/classhelpers@17877 -

svenbarth 14 years ago
parent
commit
fcf5a3a35b
2 changed files with 6 additions and 7 deletions
  1. 2 4
      compiler/pstatmnt.pas
  2. 4 3
      compiler/symtable.pas

+ 2 - 4
compiler/pstatmnt.pas

@@ -530,8 +530,7 @@ implementation
            pushobjchild(withdef,obj.childof);
            pushobjchild(withdef,obj.childof);
            { we need to look for helpers that were defined for the parent
            { we need to look for helpers that were defined for the parent
              class as well }
              class as well }
-           if not search_last_objectpascal_helper(obj,current_structdef,parenthelperdef) then
-             parenthelperdef:=nil;
+           search_last_objectpascal_helper(obj,current_structdef,parenthelperdef);
            { push the symtables of the helper's parents in reverse order }
            { push the symtables of the helper's parents in reverse order }
            if assigned(parenthelperdef) then
            if assigned(parenthelperdef) then
              pushobjchild(withdef,parenthelperdef.childof);
              pushobjchild(withdef,parenthelperdef.childof);
@@ -648,8 +647,7 @@ implementation
               extendeddef:=tobjectdef(tclassrefdef(p.resultdef).pointeddef)
               extendeddef:=tobjectdef(tclassrefdef(p.resultdef).pointeddef)
             else
             else
               extendeddef:=tabstractrecorddef(p.resultdef);
               extendeddef:=tabstractrecorddef(p.resultdef);
-            if not search_last_objectpascal_helper(extendeddef,current_structdef,helperdef) then
-              helperdef:=nil;
+            search_last_objectpascal_helper(extendeddef,current_structdef,helperdef);
             { Note: the symtable of the helper is pushed after the following
             { Note: the symtable of the helper is pushed after the following
                     "case", the symtables of the helper's parents are passed in
                     "case", the symtables of the helper's parents are passed in
                     the "case" branches }
                     the "case" branches }

+ 4 - 3
compiler/symtable.pas

@@ -2560,6 +2560,7 @@ implementation
         st: tsymtable;
         st: tsymtable;
       begin
       begin
         result:=false;
         result:=false;
+        odef:=nil;
         { when there are no helpers active currently then we don't need to do
         { when there are no helpers active currently then we don't need to do
           anything }
           anything }
         if current_module.extendeddefs.count=0 then
         if current_module.extendeddefs.count=0 then
@@ -2586,10 +2587,10 @@ implementation
                       is_visible_for_object(tobjectdef(list[i]).typesym,contextclassh);
                       is_visible_for_object(tobjectdef(list[i]).typesym,contextclassh);
               dec(i);
               dec(i);
             until result or (i<0);
             until result or (i<0);
+            if not result then
+              { just to be sure that noone uses odef }
+              odef:=nil;
           end;
           end;
-        if not result then
-          { just to be sure that noone uses odef }
-          odef:=nil;
       end;
       end;
 
 
     function search_objectpascal_helper(pd,contextclassh : tabstractrecorddef;const s: string; out srsym: tsym; out srsymtable: tsymtable):boolean;
     function search_objectpascal_helper(pd,contextclassh : tabstractrecorddef;const s: string; out srsym: tsym; out srsymtable: tsymtable):boolean;