Skip to content

Commit ae2a18b

Browse files
committed
[CS] Remove a use of typeCheckExpression in CSApply
We can just use `coerceToType` here.
1 parent a69dbb3 commit ae2a18b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/Sema/CSApply.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9452,17 +9452,17 @@ applySolutionToForEachStmtPreamble(ForEachStmt *stmt,
94529452
if (!optPatternType->isEqual(nextResultType)) {
94539453
OpaqueValueExpr *elementExpr = new (ctx) OpaqueValueExpr(
94549454
stmt->getInLoc(), nextResultType->getOptionalObjectType(),
9455-
/*isPlaceholder=*/true);
9456-
Expr *convertElementExpr = elementExpr;
9457-
if (TypeChecker::typeCheckExpression(convertElementExpr, dc,
9458-
/*contextualInfo=*/
9459-
{info.initType, CTP_CoerceOperand})
9460-
.isNull()) {
9455+
/*isPlaceholder=*/false);
9456+
cs.cacheExprTypes(elementExpr);
9457+
9458+
auto *loc = cs.getConstraintLocator(parsedSequence,
9459+
ConstraintLocator::SequenceElementType);
9460+
auto *convertExpr = solution.coerceToType(elementExpr, info.initType, loc);
9461+
if (!convertExpr)
94619462
return std::nullopt;
9462-
}
9463-
elementExpr->setIsPlaceholder(false);
9463+
94649464
stmt->setElementExpr(elementExpr);
9465-
stmt->setConvertElementExpr(convertElementExpr);
9465+
stmt->setConvertElementExpr(convertExpr);
94669466
}
94679467

94689468
// Get the conformance of the sequence type to the Sequence protocol.

0 commit comments

Comments
 (0)