Skip to content

Commit fb89d11

Browse files
committed
[ConstraintLocator] NFC: Adjust name of isForKeyPathComponent to clarify its meaning
New name is `isInKeyPathComponent` since it's implemeneted as a check for presence of `KeyPathComponent` element in the locator that covers every sub-element contained in a key path component as well.
1 parent a8ad32d commit fb89d11

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

include/swift/Sema/ConstraintLocator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ class ConstraintLocator : public llvm::FoldingSetNode {
200200
/// via key path dynamic member lookup.
201201
bool isForKeyPathDynamicMemberLookup() const;
202202

203-
/// Determine whether this locator points to one of the key path
204-
/// components.
205-
bool isForKeyPathComponent() const;
203+
/// Determine whether this locator points to element inside
204+
/// of a key path component.
205+
bool isInKeyPathComponent() const;
206206

207207
/// Determine whether this locator points to a result type of
208208
/// a key path component.

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3975,7 +3975,7 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
39753975
// If this is a reference to a static member by one of the key path
39763976
// components, let's provide a tailored diagnostic and return because
39773977
// that is unsupported so there is no fix-it.
3978-
if (locator->isForKeyPathComponent()) {
3978+
if (locator->isInKeyPathComponent()) {
39793979
InvalidStaticMemberRefInKeyPath failure(getSolution(), Member, locator);
39803980
return failure.diagnoseAsError();
39813981
}

lib/Sema/CSDiagnostics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1576,7 +1576,7 @@ class InvalidMemberRefInKeyPath : public FailureDiagnostic {
15761576
ConstraintLocator *locator)
15771577
: FailureDiagnostic(solution, locator), Member(member) {
15781578
assert(member->hasName());
1579-
assert(locator->isForKeyPathComponent() ||
1579+
assert(locator->isInKeyPathComponent() ||
15801580
locator->isForKeyPathDynamicMemberLookup());
15811581
}
15821582

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8879,7 +8879,7 @@ ConstraintSystem::simplifyKeyPathConstraint(
88798879
// than a hole. We need to come up with a better way of handling the
88808880
// relationship between key paths and overloads.
88818881
if (llvm::any_of(componentTypeVars, [&](TypeVariableType *tv) {
8882-
return tv->getImpl().getLocator()->isForKeyPathComponent() &&
8882+
return tv->getImpl().getLocator()->isInKeyPathComponent() &&
88838883
tv->getImpl().canBindToHole();
88848884
})) {
88858885
return SolutionKind::Solved;

lib/Sema/ConstraintLocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ bool ConstraintLocator::isForKeyPathDynamicMemberLookup() const {
171171
return !path.empty() && path.back().isKeyPathDynamicMember();
172172
}
173173

174-
bool ConstraintLocator::isForKeyPathComponent() const {
174+
bool ConstraintLocator::isInKeyPathComponent() const {
175175
return llvm::any_of(getPath(), [&](const LocatorPathElt &elt) {
176176
return elt.isKeyPathComponent();
177177
});

0 commit comments

Comments
 (0)