Skip to content

Commit f440dd8

Browse files
committed
[ConstraintSystem] Update key path subscript index type variable to use new locator element
1 parent d542ab9 commit f440dd8

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ class TypeVariableType::Implementation {
499499
/// expression.
500500
bool isKeyPathValue() const;
501501

502+
/// Determine whether this type variable represents an index parameter of
503+
/// a special `subscript(keyPath:)` subscript.
504+
bool isKeyPathSubscriptIndex() const;
505+
502506
/// Determine whether this type variable represents a subscript result type.
503507
bool isSubscriptResultType() const;
504508

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3687,7 +3687,7 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
36873687
// The element type is T or @lvalue T based on the key path subtype and
36883688
// the mutability of the base.
36893689
auto keyPathIndexTy = createTypeVariable(
3690-
getConstraintLocator(locator, ConstraintLocator::FunctionArgument),
3690+
getConstraintLocator(locator, ConstraintLocator::KeyPathSubscriptIndex),
36913691
TVO_CanBindToInOut);
36923692
auto elementTy = createTypeVariable(
36933693
getConstraintLocator(locator, ConstraintLocator::FunctionArgument),

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ bool TypeVariableType::Implementation::isKeyPathValue() const {
152152
return locator && locator->isKeyPathValue();
153153
}
154154

155+
bool TypeVariableType::Implementation::isKeyPathSubscriptIndex() const {
156+
return locator &&
157+
locator->isLastElement<LocatorPathElt::KeyPathSubscriptIndex>();
158+
}
159+
155160
bool TypeVariableType::Implementation::isSubscriptResultType() const {
156161
if (!(locator && locator->getAnchor()))
157162
return false;

0 commit comments

Comments
 (0)