Skip to content

Commit e5d2662

Browse files
committed
[CSSimplify] Replace locatorEndsWith with isLastElement accessor
1 parent 15e17b2 commit e5d2662

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

lib/Sema/CSSimplify.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8865,13 +8865,6 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
88658865
return cs.simplifyType(cs.getType(expr))->getRValueType();
88668866
};
88678867

8868-
auto locatorEndsWith =
8869-
[](ConstraintLocator *locator,
8870-
ConstraintLocator::PathElementKind eltKind) -> bool {
8871-
auto path = locator->getPath();
8872-
return !path.empty() && path.back().getKind() == eltKind;
8873-
};
8874-
88758868
Expr *baseExpr = nullptr;
88768869
Type baseType;
88778870

@@ -8928,7 +8921,7 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
89288921
// member.
89298922
// We need to find type variable which represents contextual base.
89308923
auto *baseLocator = cs.getConstraintLocator(
8931-
UME, locatorEndsWith(locator, ConstraintLocator::ConstructorMember)
8924+
UME, locator->isLastElement<LocatorPathElt::ConstructorMember>()
89328925
? ConstraintLocator::UnresolvedMember
89338926
: ConstraintLocator::MemberRefBase);
89348927

@@ -8943,7 +8936,7 @@ static ConstraintFix *validateInitializerRef(ConstraintSystem &cs,
89438936
baseType = cs.simplifyType(*result)->getRValueType();
89448937
// Constraint for member base is formed as '$T.Type[.<member] = ...`
89458938
// which means MetatypeType has to be added after finding a type variable.
8946-
if (locatorEndsWith(baseLocator, ConstraintLocator::MemberRefBase))
8939+
if (baseLocator->isLastElement<LocatorPathElt::MemberRefBase>())
89478940
baseType = MetatypeType::get(baseType);
89488941
} else if (auto *keyPathExpr = getAsExpr<KeyPathExpr>(anchor)) {
89498942
// Key path can't refer to initializers e.g. `\Type.init`

0 commit comments

Comments
 (0)