mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CSSimplify] Fix matchDeepEqualityTypes to allow fixing of optionals
Attempting to propagate generic argument failures up is not always
reliable, `matchDeepEqualityTypes` should avoid using `TMF_ApplyingFix`
while dealing with optionals and instead let `repairFailures` decide
whether to use generic arguments mismatch fix to a more general one.
(cherry picked from commit 27c28d4d64)
This commit is contained in:
@@ -4039,6 +4039,12 @@ ConstraintSystem::matchDeepEqualityTypes(Type type1, Type type2,
|
||||
getConstraintLocator(locator, {LocatorPathElt::GenericType(type1),
|
||||
LocatorPathElt::GenericType(type2)});
|
||||
|
||||
// Optionals have a lot of special diagnostics and only one
|
||||
// generic argument so if we're dealing with one, let's allow
|
||||
// `repairFailures` to take care of it.
|
||||
if (bound1->getDecl()->isOptionalDecl())
|
||||
return matchDeepTypeArguments(*this, subflags, args1, args2, baseLoc);
|
||||
|
||||
auto argMatchingFlags = subflags;
|
||||
// Allow the solver to produce separate fixes while matching
|
||||
// key path's root/value to a contextual type instead of the
|
||||
@@ -4049,13 +4055,6 @@ ConstraintSystem::matchDeepEqualityTypes(Type type1, Type type2,
|
||||
argMatchingFlags |= TMF_MatchingGenericArguments;
|
||||
}
|
||||
|
||||
// Optionals have a lot of special diagnostics and only one
|
||||
// generic argument so if we' re dealing with one, don't produce generic
|
||||
// arguments mismatch fixes.
|
||||
if (bound1->getDecl()->isOptionalDecl())
|
||||
return matchDeepTypeArguments(*this, argMatchingFlags, args1, args2,
|
||||
baseLoc);
|
||||
|
||||
SmallVector<unsigned, 4> mismatches;
|
||||
auto result = matchDeepTypeArguments(
|
||||
*this, argMatchingFlags, args1, args2, baseLoc,
|
||||
|
||||
Reference in New Issue
Block a user