Skip to content

Commit b61cfea

Browse files
committed
[CS] Add SolutionApplicationTarget::isForEachStmt
1 parent db53a37 commit b61cfea

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/Sema/ConstraintSystem.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,12 @@ class SolutionApplicationTarget {
14181418
/// For a pattern initialization target, retrieve the contextual pattern.
14191419
ContextualPattern getContextualPattern() const;
14201420

1421+
/// Whether this target is for a for-in statement.
1422+
bool isForEachStmt() const {
1423+
return kind == Kind::expression &&
1424+
getExprContextualTypePurpose() == CTP_ForEachStmt;
1425+
}
1426+
14211427
/// Whether this is an initialization for an Optional.Some pattern.
14221428
bool isOptionalSomePatternInit() const {
14231429
return kind == Kind::expression &&
@@ -1466,14 +1472,12 @@ class SolutionApplicationTarget {
14661472
}
14671473

14681474
const ForEachStmtInfo &getForEachStmtInfo() const {
1469-
assert(kind == Kind::expression);
1470-
assert(expression.contextualPurpose == CTP_ForEachStmt);
1475+
assert(isForEachStmt());
14711476
return expression.forEachStmt;
14721477
}
14731478

14741479
ForEachStmtInfo &getForEachStmtInfo() {
1475-
assert(kind == Kind::expression);
1476-
assert(expression.contextualPurpose == CTP_ForEachStmt);
1480+
assert(isForEachStmt());
14771481
return expression.forEachStmt;
14781482
}
14791483

0 commit comments

Comments
 (0)