Skip to content

Commit f13b00f

Browse files
[CSFix] Adjusting tuple mismatch to handle optionals
1 parent f8e3c40 commit f13b00f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/Sema/CSFix.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ getStructuralTypeContext(const Solution &solution, ConstraintLocator *locator) {
289289
} else if (auto *assignExpr = getAsExpr<AssignExpr>(locator->getAnchor())) {
290290
return std::make_tuple(CTP_AssignSource,
291291
solution.getType(assignExpr->getSrc()),
292-
solution.getType(assignExpr->getDest()));
292+
solution.getType(assignExpr->getDest())->getRValueType());
293293
} else if (auto *call = getAsExpr<CallExpr>(locator->getAnchor())) {
294294
assert(isa<TypeExpr>(call->getFn()));
295295
return std::make_tuple(
@@ -332,8 +332,10 @@ bool AllowTupleTypeMismatch::coalesceAndDiagnose(
332332
return false;
333333
}
334334

335-
TupleContextualFailure failure(solution, purpose, fromType, toType, indices,
336-
locator);
335+
TupleContextualFailure failure(solution, purpose,
336+
fromType->lookThroughAllOptionalTypes(),
337+
toType->lookThroughAllOptionalTypes(),
338+
indices, locator);
337339
return failure.diagnose(asNote);
338340
}
339341

0 commit comments

Comments
 (0)