Skip to content

Commit d9a9b59

Browse files
committed
[CodeCompletion] Skip an ASTScope assertion for labeled statements
Code completion performs 'typeCheckASTNodeAtLoc()' which ignores 'StmtChecker::ActiveLabeledStmts'. Since this is not necessary for code completions, skip an assertion to verify the correctness of ASTScope. rdar://problem/67102611
1 parent f4ae514 commit d9a9b59

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/Sema/TypeCheckStmt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> {
691691
// is equivalent to what we have here.
692692
if (LS->getStartLoc().isValid() && sourceFile &&
693693
SC.getASTContext().LangOpts.EnableASTScopeLookup &&
694-
!SC.getASTContext().Diags.hadAnyError()) {
694+
!SC.getASTContext().Diags.hadAnyError() &&
695+
!SC.LeaveBraceStmtBodyUnchecked) {
695696
// The labeled statements from ASTScope lookup have the
696697
// innermost labeled statement first, so reverse it to
697698
// match the data structure maintained here.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s > /dev/null
2+
3+
for x in "foo" {
4+
if x.#^A^# {
5+
}
6+
}

0 commit comments

Comments
 (0)