@@ -1088,38 +1088,6 @@ getMagicIdentifierLiteralKind(tok Kind) {
1088
1088
}
1089
1089
}
1090
1090
1091
- // / See if type(of: <expr>) can be parsed backtracking on failure.
1092
- static bool canParseTypeOf (Parser &P) {
1093
- // We parsed `type(of:)` as a special syntactic form in Swift 3. In Swift 4
1094
- // it is handled by overload resolution.
1095
- if (!P.Context .LangOpts .isSwiftVersion3 ())
1096
- return false ;
1097
-
1098
- if (!(P.Tok .getText () == " type" && P.peekToken ().is (tok::l_paren))) {
1099
- return false ;
1100
- }
1101
- // Look ahead to parse the parenthesized expression.
1102
- Parser::BacktrackingScope Backtrack (P);
1103
- P.consumeToken (tok::identifier);
1104
- P.consumeToken (tok::l_paren);
1105
- // The first argument label must be 'of'.
1106
- if (!(P.Tok .getText () == " of" && P.peekToken ().is (tok::colon))) {
1107
- return false ;
1108
- }
1109
-
1110
- // Parse to the closing paren.
1111
- while (!P.Tok .is (tok::r_paren) && !P.Tok .is (tok::eof)) {
1112
- // Anything that looks like another argument label is bogus. It is
1113
- // sufficient to parse for a single trailing comma. Backtracking will
1114
- // fall back to an unresolved decl.
1115
- if (P.Tok .is (tok::comma)) {
1116
- return false ;
1117
- }
1118
- P.skipSingle ();
1119
- }
1120
- return true ;
1121
- }
1122
-
1123
1091
ParserResult<Expr>
1124
1092
Parser::parseExprPostfixSuffix (ParserResult<Expr> Result, bool isExprBasic,
1125
1093
bool periodHasKeyPathBehavior,
@@ -1559,10 +1527,6 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
1559
1527
1560
1528
case tok::identifier: // foo
1561
1529
case tok::kw_self: // self
1562
- // Attempt to parse for 'type(of: <expr>)'.
1563
- if (canParseTypeOf (*this )) {
1564
- return parseExprTypeOf ();
1565
- }
1566
1530
1567
1531
// If we are parsing a refutable pattern and are inside a let/var pattern,
1568
1532
// the identifiers change to be value bindings instead of decl references.
@@ -3560,70 +3524,3 @@ Parser::parsePlatformVersionConstraintSpec() {
3560
3524
return makeParserResult (new (Context) PlatformVersionConstraintAvailabilitySpec (
3561
3525
Platform.getValue (), PlatformLoc, Version, VersionRange));
3562
3526
}
3563
-
3564
- // / parseExprTypeOf
3565
- // /
3566
- // / expr-dynamictype:
3567
- // / 'type' '(' 'of:' expr ')'
3568
- // /
3569
- ParserResult<Expr> Parser::parseExprTypeOf () {
3570
- // In libSyntax parsing, we parse 'type(of: <expr>)' as a normal function call
3571
- // expression. The semantic AST builder should treat this as a
3572
- // DynamicTypeExpr.
3573
- SyntaxParsingContext CallCtxt (SyntaxContext, SyntaxKind::FunctionCallExpr);
3574
-
3575
- SourceLoc keywordLoc;
3576
- {
3577
- SyntaxParsingContext IdentifierExprContext (SyntaxContext,
3578
- SyntaxKind::IdentifierExpr);
3579
- // Consume 'type'
3580
- keywordLoc = consumeToken ();
3581
- }
3582
-
3583
- // Parse the leading '('.
3584
- SourceLoc lParenLoc = consumeToken (tok::l_paren);
3585
-
3586
- ParserResult<Expr> subExpr;
3587
- {
3588
- SyntaxParsingContext ArgCtxt (SyntaxContext,
3589
- SyntaxKind::FunctionCallArgument);
3590
- // Parse `of` label.
3591
- if (Tok.getText () == " of" && peekToken ().is (tok::colon)) {
3592
- // Consume the label.
3593
- consumeToken ();
3594
- consumeToken (tok::colon);
3595
- } else {
3596
- // There cannot be a richer diagnostic here because the user may have
3597
- // defined a function `type(...)` that conflicts with the magic expr.
3598
- diagnose (Tok, diag::expr_typeof_expected_label_of);
3599
- }
3600
-
3601
- // Parse the subexpression.
3602
- subExpr = parseExpr (diag::expr_typeof_expected_expr);
3603
- if (subExpr.hasCodeCompletion ())
3604
- return makeParserCodeCompletionResult<Expr>();
3605
- }
3606
- CallCtxt.collectNodesInPlace (SyntaxKind::FunctionCallArgumentList);
3607
-
3608
- // Parse the closing ')'
3609
- SourceLoc rParenLoc;
3610
- if (subExpr.isParseError ()) {
3611
- skipUntilDeclStmtRBrace (tok::r_paren);
3612
- if (Tok.is (tok::r_paren))
3613
- rParenLoc = consumeToken ();
3614
- else
3615
- rParenLoc = PreviousLoc;
3616
- } else {
3617
- parseMatchingToken (tok::r_paren, rParenLoc,
3618
- diag::expr_typeof_expected_rparen, lParenLoc);
3619
- }
3620
-
3621
- // If the subexpression was in error, just propagate the error.
3622
- if (subExpr.isParseError ())
3623
- return makeParserResult<Expr>(
3624
- new (Context) ErrorExpr (SourceRange (keywordLoc, rParenLoc)));
3625
-
3626
- return makeParserResult (
3627
- new (Context) DynamicTypeExpr (keywordLoc, lParenLoc,
3628
- subExpr.get (), rParenLoc, Type ()));
3629
- }
0 commit comments