Skip to content

Commit 1b6f3a8

Browse files
authored
Merge pull request #38115 from rintaro/5.5-ide-completion-rdar78781163
[5.5][Parse] Don't skip '}' when recovering from 'default' outside 'switch'
2 parents c2172ce + 4ebab4b commit 1b6f3a8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

lib/Parse/ParseStmt.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,12 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
512512
}
513513

514514
/// Recover from a 'case' or 'default' outside of a 'switch' by consuming up to
515-
/// the next ':'.
515+
/// the next ':' or '}'.
516516
static ParserResult<Stmt> recoverFromInvalidCase(Parser &P) {
517517
assert(P.Tok.is(tok::kw_case) || P.Tok.is(tok::kw_default)
518518
&& "not case or default?!");
519519
P.diagnose(P.Tok, diag::case_outside_of_switch, P.Tok.getText());
520-
P.skipUntil(tok::colon);
520+
P.skipUntil(tok::colon, tok::r_brace);
521521
// FIXME: Return an ErrorStmt?
522522
return nullptr;
523523
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %swift-ide-test -code-completion -code-completion-token=COMPLETE -source-filename %s
2+
3+
class C {
4+
func foo() {
5+
#^COMPLETE^#
6+
default
7+
}
8+
func bar() {}
9+
}

0 commit comments

Comments
 (0)