Skip to content

Commit e1e933c

Browse files
committed
[ConstraintLocator] NFC: Add a way to check whether builder is pointing directly to some expression
1 parent 31e4465 commit e1e933c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/swift/Sema/ConstraintLocator.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,15 @@ class ConstraintLocatorBuilder {
12711271
return ConstraintLocatorBuilder(this, newElt, newFlags);
12721272
}
12731273

1274+
/// Determine whether this locator builder points directly to a
1275+
/// given expression.
1276+
template <typename E>
1277+
bool directlyAt() const {
1278+
if (auto *expr = getAnchor().dyn_cast<Expr *>())
1279+
return isa<E>(expr) && hasEmptyPath();
1280+
return false;
1281+
}
1282+
12741283
/// Determine whether this builder has an empty path.
12751284
bool hasEmptyPath() const {
12761285
return !element;

0 commit comments

Comments
 (0)