Skip to content

Commit 8b0853d

Browse files
committed
[Sema] Assert that we don't re-type-check conditions
Sink the assertion down into `TypeChecker::typeCheckCondition` and remove the old logic.
1 parent d5b3079 commit 8b0853d

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -928,13 +928,7 @@ bool TypeChecker::typeCheckForEachPreamble(DeclContext *dc, ForEachStmt *stmt,
928928
}
929929

930930
bool TypeChecker::typeCheckCondition(Expr *&expr, DeclContext *dc) {
931-
// If this expression is already typechecked and has type Bool, then just
932-
// re-typecheck it.
933-
if (expr->getType() && expr->getType()->isBool()) {
934-
auto resultTy =
935-
TypeChecker::typeCheckExpression(expr, dc);
936-
return !resultTy;
937-
}
931+
ASSERT(!expr->getType() && "the bool condition is already type checked");
938932

939933
auto *boolDecl = dc->getASTContext().getBoolDecl();
940934
if (!boolDecl)

lib/Sema/TypeCheckStmt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,6 @@ static bool typeCheckHasSymbolStmtConditionElement(StmtConditionElement &elt,
865865
static bool typeCheckBooleanStmtConditionElement(StmtConditionElement &elt,
866866
DeclContext *dc) {
867867
Expr *E = elt.getBoolean();
868-
assert(!E->getType() && "the bool condition is already type checked");
869868
bool hadError = TypeChecker::typeCheckCondition(E, dc);
870869
elt.setBoolean(E);
871870
return hadError;

0 commit comments

Comments
 (0)