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)) {
|
if (!optPatternType->isEqual(nextResultType)) {
|
||||||
OpaqueValueExpr *elementExpr = new (ctx) OpaqueValueExpr(
|
OpaqueValueExpr *elementExpr = new (ctx) OpaqueValueExpr(
|
||||||
stmt->getInLoc(), nextResultType->getOptionalObjectType(),
|
stmt->getInLoc(), nextResultType->getOptionalObjectType(),
|
||||||
/*isPlaceholder=*/true);
|
/*isPlaceholder=*/false);
|
||||||
Expr *convertElementExpr = elementExpr;
|
cs.cacheExprTypes(elementExpr);
|
||||||
if (TypeChecker::typeCheckExpression(convertElementExpr, dc,
|
|
||||||
/*contextualInfo=*/
|
auto *loc = cs.getConstraintLocator(parsedSequence,
|
||||||
{info.initType, CTP_CoerceOperand})
|
ConstraintLocator::SequenceElementType);
|
||||||
.isNull()) {
|
auto *convertExpr = solution.coerceToType(elementExpr, info.initType, loc);
|
||||||
|
if (!convertExpr)
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
|
||||||
elementExpr->setIsPlaceholder(false);
|
|
||||||
stmt->setElementExpr(elementExpr);
|
stmt->setElementExpr(elementExpr);
|
||||||
stmt->setConvertElementExpr(convertElementExpr);
|
stmt->setConvertElementExpr(convertExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the conformance of the sequence type to the Sequence protocol.
|
// Get the conformance of the sequence type to the Sequence protocol.
|
||||||
|
|||||||
Reference in New Issue
Block a user