Skip to content

Commit 1907330

Browse files
committed
[CS] Add SolutionApplicationTarget::isForEachStmt
1 parent a8f02db commit 1907330

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
@@ -1603,6 +1603,12 @@ class SolutionApplicationTarget {
16031603
/// For a pattern initialization target, retrieve the contextual pattern.
16041604
ContextualPattern getContextualPattern() const;
16051605

1606+
/// Whether this target is for a for-in statement.
1607+
bool isForEachStmt() const {
1608+
return kind == Kind::expression &&
1609+
getExprContextualTypePurpose() == CTP_ForEachStmt;
1610+
}
1611+
16061612
/// Whether this is an initialization for an Optional.Some pattern.
16071613
bool isOptionalSomePatternInit() const {
16081614
return kind == Kind::expression &&
@@ -1659,14 +1665,12 @@ class SolutionApplicationTarget {
16591665
}
16601666

16611667
const ForEachStmtInfo &getForEachStmtInfo() const {
1662-
assert(kind == Kind::expression);
1663-
assert(expression.contextualPurpose == CTP_ForEachStmt);
1668+
assert(isForEachStmt());
16641669
return expression.forEachStmt;
16651670
}
16661671

16671672
ForEachStmtInfo &getForEachStmtInfo() {
1668-
assert(kind == Kind::expression);
1669-
assert(expression.contextualPurpose == CTP_ForEachStmt);
1673+
assert(isForEachStmt());
16701674
return expression.forEachStmt;
16711675
}
16721676

0 commit comments

Comments
 (0)