Просмотр исходного кода

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 лет назад
Родитель
Сommit
fcf5a3a35b
2 измененных файлов с 6 добавлено и 7 удалено
  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);
            { we need to look for helpers that were defined for the parent
              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 }
            if assigned(parenthelperdef) then
              pushobjchild(withdef,parenthelperdef.childof);
@@ -648,8 +647,7 @@ implementation
               extendeddef:=tobjectdef(tclassrefdef(p.resultdef).pointeddef)
             else
               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
                     "case", the symtables of the helper's parents are passed in
                     the "case" branches }

+ 4 - 3
compiler/symtable.pas

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