File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed
Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments