Skip to content

Commit 8c969b8

Browse files
authored
[Sema] Assert that tap vars are in the current DeclContext (swiftlang#20303)
This assertion would have caught the last-minute bug in the string interpolation rework.
1 parent 40cfc45 commit 8c969b8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/Sema/CSGen.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3086,6 +3086,11 @@ namespace {
30863086
}
30873087

30883088
Type visitTapExpr(TapExpr *expr) {
3089+
DeclContext *varDC = expr->getVar()->getDeclContext();
3090+
assert(varDC == CS.DC || (varDC && isa<AbstractClosureExpr>(varDC) &&
3091+
cast<AbstractClosureExpr>(varDC)->hasSingleExpressionBody()) &&
3092+
"TapExpr var should be in the same DeclContext we're checking it in!");
3093+
30893094
auto locator = CS.getConstraintLocator(expr);
30903095
auto tv = CS.createTypeVariable(locator);
30913096

0 commit comments

Comments
 (0)