Skip to content

Commit ab0e8a8

Browse files
[CSSimplify] Do not record IgnoreAssignmentDestinationType or contextual if we already record a tuple mismatch
1 parent c7fdbdf commit ab0e8a8

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3356,13 +3356,19 @@ bool ConstraintSystem::repairFailures(
33563356
// related to immutability, otherwise it's a type mismatch.
33573357
auto result = matchTypes(lhs, rhs, ConstraintKind::Conversion,
33583358
TMF_ApplyingFix, locator);
3359-
3359+
3360+
auto *loc = getConstraintLocator(locator);
33603361
if (getType(destExpr)->is<LValueType>() || result.isFailure()) {
3361-
conversionsOrFixes.push_back(IgnoreAssignmentDestinationType::create(
3362-
*this, lhs, rhs, getConstraintLocator(locator)));
3362+
// Let this asignment failure be diagnosed by the AllowTupleTypeMismatch
3363+
// fix already recorded.
3364+
if (hasFixFor(loc, FixKind::AllowTupleTypeMismatch))
3365+
return true;
3366+
3367+
conversionsOrFixes.push_back(
3368+
IgnoreAssignmentDestinationType::create(*this, lhs, rhs, loc));
33633369
} else {
33643370
conversionsOrFixes.push_back(
3365-
TreatRValueAsLValue::create(*this, getConstraintLocator(locator)));
3371+
TreatRValueAsLValue::create(*this, loc));
33663372
}
33673373

33683374
return true;
@@ -8865,11 +8871,16 @@ ConstraintSystem::simplifyRestrictedConstraintImpl(
88658871
CoerceToCheckedCast::attempt(*this, fromType, toType, loc))
88668872
return !recordFix(fix, impact);
88678873
}
8868-
8874+
8875+
// We already have a fix for this locator indicating a
8876+
// tuple mismatch.
8877+
if (hasFixFor(loc, FixKind::AllowTupleTypeMismatch))
8878+
return true;
8879+
88698880
if (restriction == ConversionRestrictionKind::ValueToOptional ||
88708881
restriction == ConversionRestrictionKind::OptionalToOptional)
88718882
++impact;
8872-
8883+
88738884
auto *fix =
88748885
loc->isLastElement<LocatorPathElt::ApplyArgToParam>()
88758886
? AllowArgumentMismatch::create(*this, fromType, toType, loc)

0 commit comments

Comments
 (0)