[CSDiagnostics] Look through l-value conversions when mismatch is in subscript setter

`repairFailures` needs a special case when l-value conversion is
associated with a result type of subscript setter because otherwise
it falls through and treats result type as if it's an argument type,
which leads to crashes.

Resolves: rdar://84580119
This commit is contained in:
Pavel Yaskevich
2022-02-21 16:28:31 -08:00
parent 9297ba13d6
commit bf820c5dab
2 changed files with 32 additions and 0 deletions

View File

@@ -4563,6 +4563,14 @@ bool ConstraintSystem::repairFailures(
break;
}
// If this is a problem with result type of a subscript setter,
// let's re-attempt to repair without l-value conversion in the
// locator to fix underlying type mismatch.
if (path.back().is<LocatorPathElt::FunctionResult>()) {
return repairFailures(lhs, rhs, matchKind, conversionsOrFixes,
getConstraintLocator(anchor, path));
}
// If this is a function type param type mismatch in any position,
// the mismatch we want to report is for the whole structural type.
auto last = std::find_if(