Skip to content

Commit 7bdf016

Browse files
committed
[ConstraintSystem] Replace remaining uses of TypedNode::dyn_cast with getAsExpr
1 parent 9f02f78 commit 7bdf016

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

lib/Sema/CSSolver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,11 +705,11 @@ void ConstraintSystem::Candidate::applySolutions(
705705
continue;
706706

707707
auto anchor = choice.getFirst()->getAnchor();
708+
auto *OSR = getAsExpr<OverloadSetRefExpr>(anchor);
708709
// Anchor is not available or expression is not an overload set.
709-
if (!anchor || !isExpr<OverloadSetRefExpr>(anchor))
710+
if (!OSR)
710711
continue;
711712

712-
auto *OSR = castToExpr<OverloadSetRefExpr>(anchor);
713713
auto overload = choice.getSecond().choice;
714714
auto type = overload.getDecl()->getInterfaceType();
715715

lib/Sema/ConstraintLocator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ bool ConstraintLocator::isResultOfKeyPathDynamicMemberLookup() const {
194194
}
195195

196196
bool ConstraintLocator::isKeyPathSubscriptComponent() const {
197-
auto *anchor = getAnchor().dyn_cast<const Expr *>();
197+
auto *anchor = getAsExpr(getAnchor());
198198
auto *KPE = dyn_cast_or_null<KeyPathExpr>(anchor);
199199
if (!KPE)
200200
return false;

lib/Sema/ConstraintSystem.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,12 @@ void ConstraintSystem::assignFixedType(TypeVariableType *typeVar, Type type,
170170
if (!locator || !locator->getPath().empty())
171171
continue;
172172

173-
auto anchor = locator->getAnchor();
174-
if (!(anchor && anchor.is<const Expr *>()))
173+
auto *anchor = getAsExpr(locator->getAnchor());
174+
if (!anchor)
175175
continue;
176176

177177
literalProtocol =
178-
TypeChecker::getLiteralProtocol(getASTContext(), castToExpr(anchor));
178+
TypeChecker::getLiteralProtocol(getASTContext(), anchor);
179179
if (literalProtocol)
180180
break;
181181
}
@@ -3175,8 +3175,8 @@ bool ConstraintSystem::diagnoseAmbiguity(ArrayRef<Solution> solutions) {
31753175

31763176
// If we can't resolve the locator to an anchor expression with no path,
31773177
// we can't diagnose this well.
3178-
auto anchor = simplifyLocatorToAnchor(overload.locator);
3179-
if (!(anchor || anchor.is<const Expr *>()))
3178+
auto *anchor = getAsExpr(simplifyLocatorToAnchor(overload.locator));
3179+
if (!anchor)
31803180
continue;
31813181

31823182
auto it = indexMap.find(castToExpr(anchor));
@@ -3521,8 +3521,6 @@ TypedNode constraints::simplifyLocatorToAnchor(ConstraintLocator *locator) {
35213521
}
35223522

35233523
Expr *constraints::getArgumentExpr(TypedNode node, unsigned index) {
3524-
assert(node.is<const Expr *>());
3525-
35263524
auto *expr = castToExpr(node);
35273525
Expr *argExpr = nullptr;
35283526
if (auto *AE = dyn_cast<ApplyExpr>(expr))

0 commit comments

Comments
 (0)