Skip to content

Commit 7c7a823

Browse files
authored
Merge pull request #7203 from rintaro/parse-typeof-tweak
2 parents a19ed9c + abeaaeb commit 7c7a823

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

lib/Parse/ParseExpr.cpp

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -668,19 +668,9 @@ ParserResult<Expr> Parser::parseExprSelector() {
668668
}
669669

670670
// If the subexpression was in error, just propagate the error.
671-
if (subExpr.isParseError()) {
672-
if (subExpr.hasCodeCompletion()) {
673-
auto res = makeParserResult(
674-
new (Context) ObjCSelectorExpr(selectorKind, keywordLoc,
675-
lParenLoc, modifierLoc,
676-
subExpr.get(), rParenLoc));
677-
res.setHasCodeCompletion();
678-
return res;
679-
} else {
680-
return makeParserResult<Expr>(
681-
new (Context) ErrorExpr(SourceRange(keywordLoc, rParenLoc)));
682-
}
683-
}
671+
if (subExpr.isParseError())
672+
return makeParserResult<Expr>(
673+
new (Context) ErrorExpr(SourceRange(keywordLoc, rParenLoc)));
684674

685675
return makeParserResult<Expr>(
686676
new (Context) ObjCSelectorExpr(selectorKind, keywordLoc, lParenLoc,
@@ -3130,26 +3120,16 @@ ParserResult<Expr> Parser::parseExprTypeOf() {
31303120
if (Tok.is(tok::r_paren))
31313121
rParenLoc = consumeToken();
31323122
else
3133-
rParenLoc = Tok.getLoc();
3123+
rParenLoc = PreviousLoc;
31343124
} else {
31353125
parseMatchingToken(tok::r_paren, rParenLoc,
31363126
diag::expr_typeof_expected_rparen, lParenLoc);
31373127
}
31383128

31393129
// If the subexpression was in error, just propagate the error.
3140-
if (subExpr.isParseError()) {
3141-
if (subExpr.hasCodeCompletion()) {
3142-
auto res = makeParserResult(
3143-
new (Context) DynamicTypeExpr(keywordLoc, lParenLoc,
3144-
subExpr.get(), rParenLoc,
3145-
Type()));
3146-
res.setHasCodeCompletion();
3147-
return res;
3148-
} else {
3149-
return makeParserResult<Expr>(
3150-
new (Context) ErrorExpr(SourceRange(keywordLoc, rParenLoc)));
3151-
}
3152-
}
3130+
if (subExpr.isParseError())
3131+
return makeParserResult<Expr>(
3132+
new (Context) ErrorExpr(SourceRange(keywordLoc, rParenLoc)));
31533133

31543134
return makeParserResult(
31553135
new (Context) DynamicTypeExpr(keywordLoc, lParenLoc,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: not %target-swift-frontend %s -emit-ir
2+
3+
(!type(of:

0 commit comments

Comments
 (0)