Skip to content

Commit f9eb34a

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 169dbcd commit f9eb34a

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
@@ -3482,12 +3482,9 @@ namespace {
34823482
// Convert the subexpression.
34833483
Expr *sub = expr->getSubExpr();
34843484

3485-
solution.setExprTypes(sub);
3486-
3487-
if (TypeChecker::convertToType(sub, toType, cs.DC))
3485+
sub = solution.coerceToType(sub, toType, cs.getConstraintLocator(sub));
3486+
if (!sub)
34883487
return nullptr;
3489-
3490-
cs.cacheExprTypes(sub);
34913488

34923489
expr->setSubExpr(sub);
34933490
cs.setType(expr, toType);

0 commit comments

Comments
 (0)