[Diagnostic] Don't fix partial mismatch for sub-types associated with optional conversion

If mismatch detected by `repairFailures` is related to a complex
wrapped value of optional type formed from optional-to-optional
or value-to-optional conversion let's not try to fix it directly
but let `simplifyRestrictedConstraintImpl` record a top-level fix
for more context.

Resolves: rdar://problem/59703585
This commit is contained in:
Pavel Yaskevich
2020-03-03 00:24:23 -08:00
parent b5cb81bd0a
commit f7b264583d
3 changed files with 24 additions and 0 deletions

View File

@@ -3788,6 +3788,12 @@ bool ConstraintSystem::repairFailures(
tupleLocator->isLastElement<LocatorPathElt::GenericArgument>())
break;
// If the mismatch is a part of either optional-to-optional or
// value-to-optional conversions, let's allow fix refer to a complete
// top level type and not just a part of it.
if (tupleLocator->findLast<LocatorPathElt::OptionalPayload>())
break;
ConstraintFix *fix;
if (tupleLocator->isLastElement<LocatorPathElt::FunctionArgument>()) {
fix = AllowFunctionTypeMismatch::create(*this, lhs, rhs, tupleLocator, index);