@@ -3693,16 +3693,13 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
3693
3693
// Key path application looks like a subscript(keyPath: KeyPath<Base, T>).
3694
3694
// The element type is T or @lvalue T based on the key path subtype and
3695
3695
// the mutability of the base.
3696
- auto keyPathIndexTy = createTypeVariable(
3697
- getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
3698
- TVO_CanBindToInOut);
3696
+ auto *keyPathIndexLoc =
3697
+ getConstraintLocator(locator, ConstraintLocator::KeyPathSubscriptIndex);
3698
+ auto keyPathIndexTy = createTypeVariable(keyPathIndexLoc,
3699
+ /*options=*/0);
3699
3700
auto elementTy = createTypeVariable(
3700
- getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
3701
- TVO_CanBindToLValue | TVO_CanBindToNoEscape);
3702
- auto elementObjTy = createTypeVariable(
3703
- getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
3704
- TVO_CanBindToNoEscape);
3705
- addConstraint(ConstraintKind::Equal, elementTy, elementObjTy, locator);
3701
+ getConstraintLocator(keyPathIndexLoc, ConstraintLocator::KeyPathValue),
3702
+ TVO_CanBindToLValue | TVO_CanBindToNoEscape);
3706
3703
3707
3704
// The element result is an lvalue or rvalue based on the key path class.
3708
3705
addKeyPathApplicationConstraint(
@@ -6104,6 +6101,7 @@ void constraints::simplifyLocator(ASTNode &anchor,
6104
6101
case ConstraintLocator::OptionalPayload:
6105
6102
case ConstraintLocator::ImplicitlyUnwrappedDisjunctionChoice:
6106
6103
case ConstraintLocator::FallbackType:
6104
+ case ConstraintLocator::KeyPathSubscriptIndex:
6107
6105
break;
6108
6106
}
6109
6107
0 commit comments