File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -249,8 +249,7 @@ bool ConstraintLocator::isForOptionalTry() const {
249
249
}
250
250
251
251
bool ConstraintLocator::isForFunctionBuilderBodyResult () const {
252
- auto elt = getFirstElementAs<LocatorPathElt::FunctionBuilderBodyResult>();
253
- return elt.hasValue ();
252
+ return isFirstElement<LocatorPathElt::FunctionBuilderBodyResult>();
254
253
}
255
254
256
255
GenericTypeParamType *ConstraintLocator::getGenericParameter () const {
Original file line number Diff line number Diff line change @@ -384,6 +384,14 @@ class ConstraintLocator : public llvm::FoldingSetNode {
384
384
return anchor && isa<E>(anchor) && getPath ().empty ();
385
385
}
386
386
387
+ // / Check whether the first element in the path of this locator (if any)
388
+ // / is a given \c LocatorPathElt subclass.
389
+ template <class T >
390
+ bool isFirstElement () const {
391
+ auto path = getPath ();
392
+ return !path.empty () && path.front ().is <T>();
393
+ }
394
+
387
395
// / Attempts to cast the first path element of the locator to a specific
388
396
// / \c LocatorPathElt subclass, returning \c None if either unsuccessful or
389
397
// / the locator has no path elements.
You can’t perform that action at this time.
0 commit comments