Skip to content

Commit d1c4d78

Browse files
committed
Sema: Replace early return with ASSERT
It seems that we end up with a null Type in one place in StmtChecker::visitSwitchStmt(), so add a null check there, and a FIXME to investigate further.
1 parent f014a9a commit d1c4d78

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/Sema/TypeCheckConstraints.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,10 +1192,7 @@ TypeChecker::coerceToRValue(ASTContext &Context, Expr *expr,
11921192
llvm::function_ref<Type(Expr *)> getType,
11931193
llvm::function_ref<void(Expr *, Type)> setType) {
11941194
Type exprTy = getType(expr);
1195-
1196-
// If expr has no type, just assume it's the right expr.
1197-
if (!exprTy)
1198-
return expr;
1195+
ASSERT(exprTy);
11991196

12001197
// If the type is already materializable, then we're already done.
12011198
if (!exprTy->hasLValueType())

lib/Sema/TypeCheckStmt.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,11 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
17021702
// Type-check the subject expression.
17031703
Expr *subjectExpr = switchStmt->getSubjectExpr();
17041704
auto resultTy = TypeChecker::typeCheckExpression(subjectExpr, DC);
1705+
1706+
// FIXME: What's happening here?
1707+
if (!resultTy)
1708+
return switchStmt;
1709+
17051710
auto limitExhaustivityChecks = !resultTy;
17061711
if (Expr *newSubjectExpr =
17071712
TypeChecker::coerceToRValue(getASTContext(), subjectExpr))

0 commit comments

Comments
 (0)