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