Skip to content

Commit e5db01b

Browse files
committed
[CSClosure] Make sure that case body variables get types
Solution application needs to set interface types for variables declared in a case statement, otherwise this would lead to crashes in SILGen.
1 parent b7b492f commit e5db01b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/Sema/CSClosure.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,13 @@ class ClosureConstraintApplication
12171217
}
12181218
}
12191219

1220+
for (auto *expected : caseStmt->getCaseBodyVariablesOrEmptyArray()) {
1221+
assert(expected->hasName());
1222+
auto prev = expected->getParentVarDecl();
1223+
auto type = solution.resolveInterfaceType(solution.getType(prev));
1224+
expected->setInterfaceType(type);
1225+
}
1226+
12201227
// Translate the body.
12211228
auto *newBody = visit(caseStmt->getBody()).get<Stmt *>();
12221229
caseStmt->setBody(cast<BraceStmt>(newBody));

0 commit comments

Comments
 (0)