* 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 -
This commit is contained in:
Jonas Maebe 2012-03-25 11:37:21 +00:00
parent 69ba57f4a7
commit 2e3605e999

View File

@ -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