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 {
249249}
250250
251251bool ConstraintLocator::isForFunctionBuilderBodyResult () const {
252- auto elt = getFirstElementAs<LocatorPathElt::FunctionBuilderBodyResult>();
253- return elt.hasValue ();
252+ return isFirstElement<LocatorPathElt::FunctionBuilderBodyResult>();
254253}
255254
256255GenericTypeParamType *ConstraintLocator::getGenericParameter () const {
Original file line number Diff line number Diff line change @@ -384,6 +384,14 @@ class ConstraintLocator : public llvm::FoldingSetNode {
384384 return anchor && isa<E>(anchor) && getPath ().empty ();
385385 }
386386
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+
387395 // / Attempts to cast the first path element of the locator to a specific
388396 // / \c LocatorPathElt subclass, returning \c None if either unsuccessful or
389397 // / the locator has no path elements.
You can’t perform that action at this time.
0 commit comments