浏览代码

* fixed tobjectdef.is_related() checks in case formal class definitions are
involved and the classes are not exactly equal (but one is a child of the
other): we have to look up the real class definition first in those cases

git-svn-id: trunk@20622 -

Jonas Maebe 13 年之前
父节点
当前提交
2e3605e999
共有 1 个文件被更改,包括 10 次插入5 次删除
  1. 10 5
      compiler/symdef.pas

+ 10 - 5
compiler/symdef.pas

@@ -4979,6 +4979,7 @@ implementation
    { true, if self inherits from d (or if they are equal) }
    function tobjectdef.is_related(d : tdef) : boolean;
      var
+        realself,
         hp : tobjectdef;
      begin
         if self=d then
@@ -4992,17 +4993,21 @@ implementation
             is_related:=false;
             exit;
           end;
+        realself:=find_real_objcclass_definition(self,false);
+        d:=find_real_objcclass_definition(tobjectdef(d),false);
 
         { Objective-C protocols can use multiple inheritance }
-        if (objecttype=odt_objcprotocol) then
+        if (realself.objecttype=odt_objcprotocol) then
           begin
-            is_related:=is_related_protocol(self,d);
+            is_related:=is_related_protocol(realself,d);
             exit
           end;
 
         { formally declared Objective-C classes match Objective-C classes with
-          the same name }
-        if (objecttype=odt_objcclass) and
+          the same name (still required even though we looked up the real
+          definitions above, because these may be two different formal
+          declarations) }
+        if (realself.objecttype=odt_objcclass) and
            (tobjectdef(d).objecttype=odt_objcclass) and
            ((oo_is_formal in objectoptions) or
             (oo_is_formal in tobjectdef(d).objectoptions)) and
@@ -5012,7 +5017,7 @@ implementation
             exit;
           end;
 
-        hp:=childof;
+        hp:=realself.childof;
         while assigned(hp) do
           begin
              if hp=d then