Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1330 from 9rnsr/fix2013
Browse files Browse the repository at this point in the history
Post-processing for Issue 2013 - Remove temporary branch till the compiler migration
  • Loading branch information
rainers committed Jul 21, 2015
2 parents 4f19d34 + 60d0573 commit 9575940
Showing 1 changed file with 2 additions and 34 deletions.
36 changes: 2 additions & 34 deletions src/rt/cast_.d
Expand Up @@ -84,39 +84,8 @@ int _d_isbaseof2(ClassInfo oc, ClassInfo c, ref size_t offset)
if (oc.base is c)
return true;

version(all)
{
// Bugzilla 2013: Until the ClassInfo.interfaces[] sturcture is fixed
// (it's generated by compiler), we should keep breadth-first search
// to avoid existing code breaking.

// Before the compiler fix:
// When oc is a ClassInfo of interface type, iface.offset is always zero.
// So the offset addition has no operation.
// After the compiler fix:
// When oc is a ClassInfo of interface type, iface.offset may be nonzero.
foreach (iface; oc.interfaces)
{
if (iface.classinfo is c)
{
offset += iface.offset;
return true;
}
}

foreach (iface; oc.interfaces)
{
if (_d_isbaseof2(iface.classinfo, c, offset))
{
offset += iface.offset;
return true;
}
}
}
else
{
// Bugzilla 2013: After the compiler is actually fixed, we can simply use
// depth-first search to calculate class to base interface offset.
// Bugzilla 2013: Use depth-first search to calculate offset
// from the derived (oc) to the base (c).
foreach (iface; oc.interfaces)
{
if (iface.classinfo is c || _d_isbaseof2(iface.classinfo, c, offset))
Expand All @@ -125,7 +94,6 @@ int _d_isbaseof2(ClassInfo oc, ClassInfo c, ref size_t offset)
return true;
}
}
}

oc = oc.base;
} while(oc);
Expand Down

0 comments on commit 9575940

Please sign in to comment.