Skip to content

Commit 95d0d14

Browse files
committed
[ConstraintLocator] Add accessors for assignemnt and coerce expression
1 parent 99856ed commit 95d0d14

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/Sema/ConstraintLocator.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@ bool ConstraintLocator::isForContextualType() const {
227227
return isLastElement<LocatorPathElt::ContextualType>();
228228
}
229229

230+
bool ConstraintLocator::isForAssignment() const {
231+
auto *anchor = getAnchor();
232+
return anchor && isa<AssignExpr>(anchor) && getPath().empty();
233+
}
234+
235+
bool ConstraintLocator::isForCoercion() const {
236+
auto *anchor = getAnchor();
237+
return anchor && isa<CoerceExpr>(anchor) && getPath().empty();
238+
}
239+
230240
GenericTypeParamType *ConstraintLocator::getGenericParameter() const {
231241
// Check whether we have a path that terminates at a generic parameter.
232242
return isForGenericParameter() ?

lib/Sema/ConstraintLocator.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ class ConstraintLocator : public llvm::FoldingSetNode {
360360
/// Determine whether this locator points to the contextual type.
361361
bool isForContextualType() const;
362362

363+
/// Determine whether this locator points to the assignment expression.
364+
bool isForAssignment() const;
365+
366+
/// Determine whether this locator points to the coercion expression.
367+
bool isForCoercion() const;
368+
363369
/// Attempts to cast the first path element of the locator to a specific
364370
/// \c LocatorPathElt subclass, returning \c None if either unsuccessful or
365371
/// the locator has no path elements.

0 commit comments

Comments
 (0)