@@ -1774,14 +1774,8 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
1774
1774
Tok.getLoc ().getAdvancedLoc (1 ) == peekToken ().getLoc ()) {
1775
1775
return parseExprPoundCodeCompletion (/* ParentKind*/ None);
1776
1776
}
1777
- if (Context.LangOpts .hasFeature (Feature::Macros)) {
1778
- return parseExprMacroExpansion (isExprBasic);
1779
- }
1780
- if (peekToken ().is (tok::identifier) && !peekToken ().isEscapedIdentifier () &&
1781
- Tok.getLoc ().getAdvancedLoc (1 ) == peekToken ().getLoc ()) {
1782
- return parseExprPoundUnknown (SourceLoc ());
1783
- }
1784
- goto UnknownCharacter;
1777
+
1778
+ return parseExprMacroExpansion (isExprBasic);
1785
1779
1786
1780
// Eat an invalid token in an expression context. Error tokens are diagnosed
1787
1781
// by the lexer, so there is no reason to emit another diagnostic.
@@ -3245,82 +3239,6 @@ Parser::parseExprObjectLiteral(ObjectLiteralExpr::LiteralKind LitKind,
3245
3239
/* implicit*/ false ));
3246
3240
}
3247
3241
3248
- // / Parse and diagnose unknown pound expression
3249
- // /
3250
- // / If it look like a legacy (Swift 2) object literal expression, suggest fix-it
3251
- // / to use new object literal syntax.
3252
- // /
3253
- // / expr-unknown-pound:
3254
- // / '#' identifier expr-paren?
3255
- // / '[' '#' identifier expr-paren? '#' ']' ; Legacy object literal
3256
- ParserResult<Expr> Parser::parseExprPoundUnknown (SourceLoc LSquareLoc) {
3257
- SourceLoc PoundLoc = consumeToken (tok::pound);
3258
-
3259
- assert (Tok.is (tok::identifier) && !Tok.isEscapedIdentifier () &&
3260
- PoundLoc.getAdvancedLoc (1 ) == Tok.getLoc ());
3261
-
3262
- Identifier Name;
3263
- SourceLoc NameLoc = consumeIdentifier (Name, /* diagnoseDollarPrefix=*/ false );
3264
-
3265
- // Parse arguments if exist.
3266
- ArgumentList *ArgList = nullptr ;
3267
- if (Tok.isFollowingLParen ()) {
3268
- // Parse arguments.
3269
- auto result = parseArgumentList (tok::l_paren, tok::r_paren,
3270
- /* isExprBasic*/ true );
3271
- if (result.hasCodeCompletion ())
3272
- return makeParserCodeCompletionResult<Expr>();
3273
- if (result.isParseErrorOrHasCompletion ())
3274
- return makeParserError ();
3275
- ArgList = result.get ();
3276
- }
3277
-
3278
- std::pair<StringRef, StringRef> NewNameArgPair =
3279
- llvm::StringSwitch<std::pair<StringRef, StringRef>>(Name.str ())
3280
- .Case (" Color" , {" colorLiteral" , " red" })
3281
- .Case (" Image" , {" imageLiteral" , " resourceName" })
3282
- .Case (" FileReference" , {" fileLiteral" , " resourceName" })
3283
- .Default ({});
3284
-
3285
- // If it's not legacy object literal, we don't know how to handle this.
3286
- if (NewNameArgPair.first .empty ()) {
3287
- diagnose (PoundLoc, diag::unknown_pound_expr, Name.str ());
3288
- return makeParserError ();
3289
- }
3290
-
3291
- // Diagnose legacy object literal.
3292
-
3293
- // Didn't have arguments.
3294
- if (!ArgList || ArgList->getLParenLoc ().isInvalid ()) {
3295
- diagnose (Tok.getLoc (), diag::expected_arg_list_in_object_literal);
3296
- return makeParserError ();
3297
- }
3298
-
3299
- // If it's started with '[', try to parse closing '#]'.
3300
- SourceLoc RPoundLoc, RSquareLoc;
3301
- if (LSquareLoc.isValid () && consumeIf (tok::pound, RPoundLoc))
3302
- consumeIf (tok::r_square, RSquareLoc);
3303
-
3304
- auto diag = diagnose (LSquareLoc.isValid () ? LSquareLoc : PoundLoc,
3305
- diag::legacy_object_literal, LSquareLoc.isValid (),
3306
- Name.str (), NewNameArgPair.first );
3307
-
3308
- // Remove '[' if exist.
3309
- if (LSquareLoc.isValid ())
3310
- diag.fixItRemove (LSquareLoc);
3311
- // Replace the literal name.
3312
- diag.fixItReplace (NameLoc, NewNameArgPair.first );
3313
- // Replace the first argument.
3314
- if (!ArgList->empty () && ArgList->front ().getLabelLoc ().isValid ())
3315
- diag.fixItReplace (ArgList->front ().getLabelLoc (), NewNameArgPair.second );
3316
- // Remove '#]' if exist.
3317
- if (RPoundLoc.isValid ())
3318
- diag.fixItRemove (
3319
- {RPoundLoc, RSquareLoc.isValid () ? RSquareLoc : RPoundLoc});
3320
-
3321
- return makeParserError ();
3322
- }
3323
-
3324
3242
// / Handle code completion after pound in expression position.
3325
3243
// /
3326
3244
// / In case it's in a stmt condition position, specify \p ParentKind to
@@ -3460,14 +3378,6 @@ ParserResult<Expr> Parser::parseExprCollection() {
3460
3378
DictionaryExpr::create (Context, LSquareLoc, {}, {}, RSquareLoc));
3461
3379
}
3462
3380
3463
- // [#identifier is likely to be a legacy object literal.
3464
- if (Tok.is (tok::pound) && peekToken ().is (tok::identifier) &&
3465
- !peekToken ().isEscapedIdentifier () &&
3466
- LSquareLoc.getAdvancedLoc (1 ) == Tok.getLoc () &&
3467
- Tok.getLoc ().getAdvancedLoc (1 ) == peekToken ().getLoc ()) {
3468
- return parseExprPoundUnknown (LSquareLoc);
3469
- }
3470
-
3471
3381
ParserStatus Status;
3472
3382
Optional<bool > isDictionary;
3473
3383
SmallVector<Expr *, 8 > ElementExprs;
0 commit comments