mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Merge pull request #85739 from hamishknight/direct-conv
This commit is contained in:
@@ -9452,17 +9452,17 @@ applySolutionToForEachStmtPreamble(ForEachStmt *stmt,
|
||||
if (!optPatternType->isEqual(nextResultType)) {
|
||||
OpaqueValueExpr *elementExpr = new (ctx) OpaqueValueExpr(
|
||||
stmt->getInLoc(), nextResultType->getOptionalObjectType(),
|
||||
/*isPlaceholder=*/true);
|
||||
Expr *convertElementExpr = elementExpr;
|
||||
if (TypeChecker::typeCheckExpression(convertElementExpr, dc,
|
||||
/*contextualInfo=*/
|
||||
{info.initType, CTP_CoerceOperand})
|
||||
.isNull()) {
|
||||
/*isPlaceholder=*/false);
|
||||
cs.cacheExprTypes(elementExpr);
|
||||
|
||||
auto *loc = cs.getConstraintLocator(parsedSequence,
|
||||
ConstraintLocator::SequenceElementType);
|
||||
auto *convertExpr = solution.coerceToType(elementExpr, info.initType, loc);
|
||||
if (!convertExpr)
|
||||
return std::nullopt;
|
||||
}
|
||||
elementExpr->setIsPlaceholder(false);
|
||||
|
||||
stmt->setElementExpr(elementExpr);
|
||||
stmt->setConvertElementExpr(convertElementExpr);
|
||||
stmt->setConvertElementExpr(convertExpr);
|
||||
}
|
||||
|
||||
// Get the conformance of the sequence type to the Sequence protocol.
|
||||
|
||||
Reference in New Issue
Block a user