Skip to content

Commit f84b3d4

Browse files
committed
[CSSimplify] Allow fixing root/value mismatches of a key path literal individually
In general the solver attempts to gather all of the generic argument mismatches into a single fix because there could be an arbitrary number of generic arguments. This is uncessary for key path literals matching against a contextual type because they have at most two generic arguments (Root and Value), so it's better to produce fixes for root and value type individually.
1 parent 9f21b95 commit f84b3d4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,8 +3789,15 @@ ConstraintSystem::matchDeepEqualityTypes(Type type1, Type type2,
37893789
getConstraintLocator(locator, {LocatorPathElt::GenericType(bound1),
37903790
LocatorPathElt::GenericType(bound2)});
37913791

3792-
auto argMatchingFlags =
3793-
subflags | TMF_ApplyingFix | TMF_MatchingGenericArguments;
3792+
auto argMatchingFlags = subflags;
3793+
// Allow the solver to produce separate fixes while matching
3794+
// key path's root/value to a contextual type instead of the
3795+
// standard one fix for all mismatched generic arguments
3796+
// because at least one side of such a relation would be resolved.
3797+
if (!isExpr<KeyPathExpr>(locator.trySimplifyToExpr())) {
3798+
argMatchingFlags |= TMF_ApplyingFix;
3799+
argMatchingFlags |= TMF_MatchingGenericArguments;
3800+
}
37943801

37953802
// Optionals have a lot of special diagnostics and only one
37963803
// generic argument so if we' re dealing with one, don't produce generic

0 commit comments

Comments
 (0)