Skip to content

Commit

Permalink
Remove CallExp::implicitCastTo altogether.
Browse files Browse the repository at this point in the history
The pure -> immutable case is checked in implicitConvTo as well,
and since it yields MATCHexact, the castTo() in
Expression::implicitCastTo is a no-op anyway.
  • Loading branch information
dnadlinger committed Jan 25, 2014
1 parent 8061924 commit 4bfca03
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
21 changes: 0 additions & 21 deletions src/cast.c
Expand Up @@ -610,27 +610,6 @@ MATCH AssocArrayLiteralExp::implicitConvTo(Type *t)
return Expression::implicitConvTo(t);
}

Expression *CallExp::implicitCastTo(Scope *sc, Type *t)
{
//printf("CallExp::implicitCastTo(%s of type %s) => %s\n", toChars(), type->toChars(), t->toChars());

/* Allow the result of strongly pure functions to
* convert to immutable
*/
if (f && f->isolateReturn() &&
type->immutableOf()->equals(t))
{
/* Avoid emitting CastExp for:
* T[] make() pure { ... }
* immutable T[] arr = make(); // unique return
*/
Expression *e = copy();
e->type = t;
return e;
}
return Expression::implicitCastTo(sc, t);
}

MATCH CallExp::implicitConvTo(Type *t)
{
#if 0
Expand Down
1 change: 0 additions & 1 deletion src/expression.h
Expand Up @@ -1103,7 +1103,6 @@ class CallExp : public UnaExp
int isLvalue();
Expression *toLvalue(Scope *sc, Expression *e);
Expression *addDtorHook(Scope *sc);
Expression *implicitCastTo(Scope *sc, Type *t);
MATCH implicitConvTo(Type *t);

Expression *doInline(InlineDoState *ids);
Expand Down

0 comments on commit 4bfca03

Please sign in to comment.