@@ -748,13 +748,11 @@ ParserResult<Expr> Parser::parseExprKeyPath() {
748748 }
749749
750750 auto inner = makeParserResult (new (Context) KeyPathDotExpr (dotLoc));
751- bool unusedHasBindOptional = false ;
752751
753752 // Inside a keypath's path, the period always behaves normally: the key path
754753 // behavior is only the separation between type and path.
755754 pathResult = parseExprPostfixSuffix (inner, /* isExprBasic=*/ true ,
756- /* periodHasKeyPathBehavior=*/ false ,
757- unusedHasBindOptional);
755+ /* periodHasKeyPathBehavior=*/ false );
758756 parseStatus |= pathResult;
759757 }
760758
@@ -1229,10 +1227,7 @@ getMagicIdentifierLiteralKind(tok Kind, const LangOptions &Opts) {
12291227
12301228ParserResult<Expr>
12311229Parser::parseExprPostfixSuffix (ParserResult<Expr> Result, bool isExprBasic,
1232- bool periodHasKeyPathBehavior,
1233- bool &hasBindOptional) {
1234- hasBindOptional = false ;
1235-
1230+ bool periodHasKeyPathBehavior) {
12361231 // Handle suffix expressions.
12371232 while (1 ) {
12381233 // FIXME: Better recovery.
@@ -1318,9 +1313,8 @@ Parser::parseExprPostfixSuffix(ParserResult<Expr> Result, bool isExprBasic,
13181313 // In this case, we want to consume the trailing closure because
13191314 // otherwise it will get parsed as a get-set clause on a variable
13201315 // declared by `baseExpr.<complete>` which is clearly wrong.
1321- bool hasBindOptional = false ;
13221316 parseExprPostfixSuffix (makeParserResult (CCExpr), isExprBasic,
1323- periodHasKeyPathBehavior, hasBindOptional );
1317+ periodHasKeyPathBehavior);
13241318
13251319 return makeParserCodeCompletionResult (CCExpr);
13261320 }
@@ -1410,7 +1404,6 @@ Parser::parseExprPostfixSuffix(ParserResult<Expr> Result, bool isExprBasic,
14101404 if (consumeIf (tok::question_postfix)) {
14111405 Result = makeParserResult (Result, new (Context) BindOptionalExpr (
14121406 Result.get (), TokLoc, /* depth*/ 0 ));
1413- hasBindOptional = true ;
14141407 continue ;
14151408 }
14161409
@@ -1479,19 +1472,14 @@ Parser::parseExprPostfixSuffix(ParserResult<Expr> Result, bool isExprBasic,
14791472 }
14801473
14811474 llvm::TinyPtrVector<ASTNode> activeElements;
1482- llvm::SmallPtrSet<Expr *, 4 > exprsWithBindOptional;
14831475 auto ICD = parseIfConfig (
14841476 IfConfigContext::PostfixExpr,
14851477 [&](bool isActive) {
14861478 // Although we know the '#if' body starts with period,
14871479 // '#elseif'/'#else' bodies might start with invalid tokens.
14881480 if (isAtStartOfPostfixExprSuffix () || Tok.is (tok::pound_if)) {
1489- bool exprHasBindOptional = false ;
14901481 auto expr = parseExprPostfixSuffix (Result, isExprBasic,
1491- periodHasKeyPathBehavior,
1492- exprHasBindOptional);
1493- if (exprHasBindOptional)
1494- exprsWithBindOptional.insert (expr.get ());
1482+ periodHasKeyPathBehavior);
14951483
14961484 if (isActive)
14971485 activeElements.push_back (expr.get ());
@@ -1513,7 +1501,6 @@ Parser::parseExprPostfixSuffix(ParserResult<Expr> Result, bool isExprBasic,
15131501 if (SourceMgr.rangeContainsIDEInspectionTarget (charRange) &&
15141502 L->isCodeCompletion ())
15151503 status.setHasCodeCompletion ();
1516- hasBindOptional |= exprsWithBindOptional.contains (expr);
15171504 Result = makeParserResult (status, expr);
15181505 continue ;
15191506 }
@@ -1609,20 +1596,8 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
16091596 if (Result.isNull ())
16101597 return Result;
16111598
1612- bool hasBindOptional = false ;
1613- Result = parseExprPostfixSuffix (Result, isExprBasic,
1614- /* periodHasKeyPathBehavior=*/ InSwiftKeyPath,
1615- hasBindOptional);
1616- if (Result.isParseErrorOrHasCompletion () || Result.hasCodeCompletion ())
1617- return Result;
1618-
1619- // If we had a ? suffix expression, bind the entire postfix chain
1620- // within an OptionalEvaluationExpr.
1621- if (hasBindOptional) {
1622- Result = makeParserResult (new (Context) OptionalEvaluationExpr (Result.get ()));
1623- }
1624-
1625- return Result;
1599+ return parseExprPostfixSuffix (Result, isExprBasic,
1600+ /* periodHasKeyPathBehavior=*/ InSwiftKeyPath);
16261601}
16271602
16281603// / parseExprPrimary
0 commit comments