Skip to content

Commit 2b8518b

Browse files
committed
[ConstraintSystem] Add a way to check whether a given type variable represents a closure parameter type
1 parent b5568e0 commit 2b8518b

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/Sema/ConstraintSystem.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,10 @@ class TypeVariableType::Implementation {
301301
/// Determine whether this type variable represents a closure type.
302302
bool isClosureType() const;
303303

304+
/// Determine whether this type variable represents one of the
305+
/// parameter types associated with a closure.
306+
bool isClosureParameterType() const;
307+
304308
/// Determine whether this type variable represents a closure result type.
305309
bool isClosureResultType() const;
306310

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ bool TypeVariableType::Implementation::isClosureType() const {
9090
return isExpr<ClosureExpr>(locator->getAnchor()) && locator->getPath().empty();
9191
}
9292

93+
bool TypeVariableType::Implementation::isClosureParameterType() const {
94+
if (!(locator && locator->getAnchor()))
95+
return false;
96+
97+
return isExpr<ClosureExpr>(locator->getAnchor()) &&
98+
locator->isLastElement<LocatorPathElt::TupleElement>();
99+
}
100+
93101
bool TypeVariableType::Implementation::isClosureResultType() const {
94102
if (!(locator && locator->getAnchor()))
95103
return false;

0 commit comments

Comments
 (0)