Skip to content

Commit

Permalink
Revert "Revert "(DELETE, the proper fix is remove cpp::getRightThis) …
Browse files Browse the repository at this point in the history
…(Issue #65) Disable overloading by opCast when a CastExp is a downcast to a C++ base.""

This reverts commit e7fb20a.
  • Loading branch information
Syniurge committed Mar 13, 2018
1 parent e7fb20a commit a713ddf
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ddmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -4289,7 +4289,20 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
return;
}

if (!exp.to.equals(exp.e1.type) && exp.mod == cast(ubyte)~0)
Type t1b = exp.e1.type.toBasetype();
Type tob = exp.to.toBasetype();

// CALYPSO HACK: disable overloading by opCast if exp.type is a C++ base of exp.e1.type
// See issue #65: https://github.com/Syniurge/Calypso/issues/65
bool disableOpCast = false;

auto t1ad = getAggregateSym(t1b);
ClassDeclaration t1cd = t1ad ? t1ad.isClassDeclaration() : null;
auto toad = getAggregateSym(tob);
if (toad && t1cd && toad.langPlugin() && toad.isBaseOf(t1cd, null))
disableOpCast = true;

if (!exp.to.equals(exp.e1.type) && exp.mod == cast(ubyte)~0 && !disableOpCast)
{
if (Expression e = exp.op_overload(sc))
{
Expand All @@ -4298,9 +4311,6 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}
}

Type t1b = exp.e1.type.toBasetype();
Type tob = exp.to.toBasetype();

if (tob.ty == Tstruct && !tob.equals(t1b))
{
/* Look to replace:
Expand Down

0 comments on commit a713ddf

Please sign in to comment.