Skip to content

Commit 00994f1

Browse files
author
Nathan Hawes
committed
[Parse] Stop early exiting when parsing catch statements and ObjCSelector expressions that contain code completions.
1 parent c4f0505 commit 00994f1

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,8 +802,6 @@ ParserResult<Expr> Parser::parseExprSelector() {
802802
parseExpr(selectorKind == ObjCSelectorExpr::Method
803803
? diag::expr_selector_expected_method_expr
804804
: diag::expr_selector_expected_property_expr);
805-
if (subExpr.hasCodeCompletion())
806-
return makeParserCodeCompletionResult<Expr>();
807805

808806
// Parse the closing ')'.
809807
SourceLoc rParenLoc;
@@ -819,7 +817,7 @@ ParserResult<Expr> Parser::parseExprSelector() {
819817
}
820818

821819
// If the subexpression was in error, just propagate the error.
822-
if (subExpr.isParseError())
820+
if (subExpr.isParseError() && !subExpr.hasCodeCompletion())
823821
return makeParserResult<Expr>(
824822
new (Context) ErrorExpr(SourceRange(keywordLoc, rParenLoc)));
825823

lib/Parse/ParseStmt.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,9 +2013,6 @@ ParserResult<CaseStmt> Parser::parseStmtCatch() {
20132013
GuardedPattern PatternResult;
20142014
parseGuardedPattern(*this, PatternResult, status, boundDecls,
20152015
GuardedPatternContext::Catch, isFirst);
2016-
if (status.hasCodeCompletion()) {
2017-
return makeParserCodeCompletionResult<CaseStmt>();
2018-
}
20192016
caseLabelItems.emplace_back(PatternResult.ThePattern,
20202017
PatternResult.WhereLoc, PatternResult.Guard);
20212018
isFirst = false;

test/IDE/complete_exception.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ func test001() {
7272
do {} catch #^CATCH1^#
7373

7474
// CATCH1: Begin completions
75-
// CATCH1-DAG: Decl[Enum]/CurrModule: Error4[#Error4#]; name=Error4{{$}}
76-
// CATCH1-DAG: Decl[Class]/CurrModule: Error3[#Error3#]; name=Error3{{$}}
77-
// CATCH1-DAG: Decl[Class]/CurrModule: Error2[#Error2#]; name=Error2{{$}}
78-
// CATCH1-DAG: Decl[Class]/CurrModule: Error1[#Error1#]; name=Error1{{$}}
75+
// CATCH1-DAG: Decl[Enum]/CurrModule/TypeRelation[Convertible]: Error4[#Error4#]; name=Error4{{$}}
76+
// CATCH1-DAG: Decl[Class]/CurrModule/TypeRelation[Convertible]: Error3[#Error3#]; name=Error3{{$}}
77+
// CATCH1-DAG: Decl[Class]/CurrModule/TypeRelation[Convertible]: Error2[#Error2#]; name=Error2{{$}}
78+
// CATCH1-DAG: Decl[Class]/CurrModule/TypeRelation[Convertible]: Error1[#Error1#]; name=Error1{{$}}
7979
// CATCH1-DAG: Keyword[let]/None: let{{; name=.+$}}
8080
// CATCH1-DAG: Decl[Class]/CurrModule: NoneError1[#NoneError1#]; name=NoneError1{{$}}
8181
// CATCH1-DAG: Decl[Class]/OtherModule[Foundation]/IsSystem: NSError[#NSError#]{{; name=.+$}}

0 commit comments

Comments
 (0)