Skip to content

Commit d379de8

Browse files
committed
[Constraint solver] Switch coercion to be solution-based.
Rather than spinning up a new constraint system when performing an "as" coercion, perform the coercion with the known solution, because we already did all of the work to figure out how to perform the coercion.
1 parent 4cd873a commit d379de8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3530,12 +3530,9 @@ namespace {
35303530
// Convert the subexpression.
35313531
Expr *sub = expr->getSubExpr();
35323532

3533-
solution.setExprTypes(sub);
3534-
3535-
if (TypeChecker::convertToType(sub, toType, cs.DC))
3533+
sub = solution.coerceToType(sub, toType, cs.getConstraintLocator(sub));
3534+
if (!sub)
35363535
return nullptr;
3537-
3538-
cs.cacheExprTypes(sub);
35393536

35403537
expr->setSubExpr(sub);
35413538
cs.setType(expr, toType);

0 commit comments

Comments
 (0)