Skip to content

Commit f620f76

Browse files
[Sema] Renaming missing component key path fix and failure
1 parent d9294e8 commit f620f76

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
12271227
// If we recorded a invalid key path fix, let's skip this root fix
12281228
// because it wouldn't produce a useful diagnostic.
12291229
auto *kpLocator = cs.getConstraintLocator(srcLocator->getAnchor());
1230-
if (cs.hasFixFor(kpLocator, FixKind::AllowKeyPathMissingComponent))
1230+
if (cs.hasFixFor(kpLocator, FixKind::AllowKeyPathWithoutComponents))
12311231
return true;
12321232

12331233
fix = SpecifyKeyPathRootType::create(cs, dstLocator);

lib/Sema/CSDiagnostics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6761,7 +6761,7 @@ void TrailingClosureRequiresExplicitLabel::fixIt(
67616761
isExpr<SubscriptExpr>(anchor) ? "]" : ")");
67626762
}
67636763

6764-
bool AllowKeyPathMissingComponentFailure::diagnoseAsError() {
6764+
bool InvalidEmptyKeyPathFailure::diagnoseAsError() {
67656765
auto *KPE = getAsExpr<KeyPathExpr>(getAnchor());
67666766
assert(KPE && KPE->hasSingleInvalidComponent() &&
67676767
"Expected a malformed key path expression");

lib/Sema/CSDiagnostics.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2253,10 +2253,10 @@ class TrailingClosureRequiresExplicitLabel final : public FailureDiagnostic {
22532253
/// \code
22542254
/// let _ : KeyPath<A, B> = \A
22552255
/// \endcode
2256-
class AllowKeyPathMissingComponentFailure final : public FailureDiagnostic {
2256+
class InvalidEmptyKeyPathFailure final : public FailureDiagnostic {
22572257
public:
2258-
AllowKeyPathMissingComponentFailure(const Solution &solution,
2259-
ConstraintLocator *locator)
2258+
InvalidEmptyKeyPathFailure(const Solution &solution,
2259+
ConstraintLocator *locator)
22602260
: FailureDiagnostic(solution, locator) {}
22612261

22622262
bool diagnoseAsError() override;

lib/Sema/CSFix.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,14 +1540,14 @@ SpecifyLabelToAssociateTrailingClosure::create(ConstraintSystem &cs,
15401540
SpecifyLabelToAssociateTrailingClosure(cs, locator);
15411541
}
15421542

1543-
bool AllowKeyPathMissingComponent::diagnose(const Solution &solution,
1544-
bool asNote) const {
1545-
AllowKeyPathMissingComponentFailure failure(solution, getLocator());
1543+
bool AllowKeyPathWithoutComponents::diagnose(const Solution &solution,
1544+
bool asNote) const {
1545+
InvalidEmptyKeyPathFailure failure(solution, getLocator());
15461546
return failure.diagnose(asNote);
15471547
}
15481548

1549-
AllowKeyPathMissingComponent *
1550-
AllowKeyPathMissingComponent::create(ConstraintSystem &cs,
1551-
ConstraintLocator *locator) {
1552-
return new (cs.getAllocator()) AllowKeyPathMissingComponent(cs, locator);
1549+
AllowKeyPathWithoutComponents *
1550+
AllowKeyPathWithoutComponents::create(ConstraintSystem &cs,
1551+
ConstraintLocator *locator) {
1552+
return new (cs.getAllocator()) AllowKeyPathWithoutComponents(cs, locator);
15531553
}

lib/Sema/CSFix.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ enum class FixKind : uint8_t {
275275
SpecifyLabelToAssociateTrailingClosure,
276276

277277
/// Allow key path expressions missing component.
278-
AllowKeyPathMissingComponent,
278+
AllowKeyPathWithoutComponents,
279279
};
280280

281281
class ConstraintFix {
@@ -1966,17 +1966,18 @@ class SpecifyLabelToAssociateTrailingClosure final : public ConstraintFix {
19661966
/// \code
19671967
/// let _ : KeyPath<A, B> = \A
19681968
/// \endcode
1969-
class AllowKeyPathMissingComponent final : public ConstraintFix {
1970-
AllowKeyPathMissingComponent(ConstraintSystem &cs, ConstraintLocator *locator)
1971-
: ConstraintFix(cs, FixKind::AllowKeyPathMissingComponent, locator) {}
1969+
class AllowKeyPathWithoutComponents final : public ConstraintFix {
1970+
AllowKeyPathWithoutComponents(ConstraintSystem &cs,
1971+
ConstraintLocator *locator)
1972+
: ConstraintFix(cs, FixKind::AllowKeyPathWithoutComponents, locator) {}
19721973

19731974
public:
19741975
std::string getName() const override { return "key path missing component"; }
19751976

19761977
bool diagnose(const Solution &solution, bool asNote = false) const override;
19771978

1978-
static AllowKeyPathMissingComponent *create(ConstraintSystem &cs,
1979-
ConstraintLocator *locator);
1979+
static AllowKeyPathWithoutComponents *create(ConstraintSystem &cs,
1980+
ConstraintLocator *locator);
19801981
};
19811982

19821983
} // end namespace constraints

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8130,7 +8130,7 @@ ConstraintSystem::simplifyKeyPathConstraint(
81308130
// If we have a malformed KeyPathExpr e.g. let _: KeyPath<A, C> = \A
81318131
// let's record a AllowKeyPathMissingComponent fix.
81328132
if (keyPath->hasSingleInvalidComponent()) {
8133-
auto *fix = AllowKeyPathMissingComponent::create(
8133+
auto *fix = AllowKeyPathWithoutComponents::create(
81348134
*this, getConstraintLocator(locator));
81358135
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
81368136
}
@@ -9997,7 +9997,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyFixConstraint(
99979997
case FixKind::AllowCoercionToForceCast:
99989998
case FixKind::SpecifyKeyPathRootType:
99999999
case FixKind::SpecifyLabelToAssociateTrailingClosure:
10000-
case FixKind::AllowKeyPathMissingComponent: {
10000+
case FixKind::AllowKeyPathWithoutComponents: {
1000110001
return recordFix(fix) ? SolutionKind::Error : SolutionKind::Solved;
1000210002
}
1000310003

0 commit comments

Comments
 (0)