@@ -745,7 +745,8 @@ ParserResult<Expr> Parser::parseExprKeyPathObjC() {
745745 // Parse the sequence of unqualified-names.
746746 ParserStatus status;
747747 SourceLoc LastDotLoc;
748- DeclNameOptions flags = DeclNameFlag::AllowCompoundNames;
748+ DeclNameOptions flags = DeclNameFlag::AllowCompoundNames |
749+ DeclNameFlag::AllowLowercaseAndUppercaseSelf;
749750 while (true ) {
750751 // Handle code completion.
751752 if (Tok.is (tok::code_complete))
@@ -1272,8 +1273,10 @@ Parser::parseExprPostfixSuffix(ParserResult<Expr> Result, bool isExprBasic,
12721273 Diag<> D = isa<SuperRefExpr>(Result.get ())
12731274 ? diag::expected_identifier_after_super_dot_expr
12741275 : diag::expected_member_name;
1275- auto Name = parseDeclNameRef (NameLoc, D,
1276- DeclNameFlag::AllowKeywords | DeclNameFlag::AllowCompoundNames);
1276+ auto Name = parseDeclNameRef (
1277+ NameLoc, D,
1278+ DeclNameFlag::AllowKeywords | DeclNameFlag::AllowCompoundNames |
1279+ DeclNameFlag::AllowLowercaseAndUppercaseSelf);
12771280 if (!Name) {
12781281 SourceRange ErrorRange = Result.get ()->getSourceRange ();
12791282 ErrorRange.widen (TokLoc);
@@ -1756,7 +1759,9 @@ ParserResult<Expr> Parser::parseExprPrimary(Diag<> ID, bool isExprBasic) {
17561759 }
17571760
17581761 Name = parseDeclNameRef (NameLoc, diag::expected_identifier_after_dot_expr,
1759- DeclNameFlag::AllowKeywords | DeclNameFlag::AllowCompoundNames);
1762+ DeclNameFlag::AllowKeywords |
1763+ DeclNameFlag::AllowCompoundNames |
1764+ DeclNameFlag::AllowLowercaseAndUppercaseSelf);
17601765 if (!Name)
17611766 return makeParserErrorResult (new (Context) ErrorExpr (DotLoc));
17621767
@@ -2205,7 +2210,9 @@ DeclNameRef Parser::parseDeclNameRef(DeclNameLoc &loc,
22052210 // Consume the base name.
22062211 DeclBaseName baseName;
22072212 SourceLoc baseNameLoc;
2208- if (Tok.isAny (tok::identifier, tok::kw_Self, tok::kw_self)) {
2213+ if (Tok.is (tok::identifier) ||
2214+ (flags.contains (DeclNameFlag::AllowLowercaseAndUppercaseSelf) &&
2215+ Tok.isAny (tok::kw_Self, tok::kw_self))) {
22092216 Identifier baseNameId;
22102217 baseNameLoc = consumeIdentifier (baseNameId, /* diagnoseDollarPrefix=*/ false );
22112218 baseName = baseNameId;
@@ -2266,8 +2273,10 @@ ParserResult<Expr> Parser::parseExprIdentifier() {
22662273
22672274 // Parse the unqualified-decl-name.
22682275 DeclNameLoc loc;
2269- DeclNameRef name = parseDeclNameRef (loc, diag::expected_expr,
2270- DeclNameFlag::AllowCompoundNames);
2276+ DeclNameRef name =
2277+ parseDeclNameRef (loc, diag::expected_expr,
2278+ DeclNameFlag::AllowCompoundNames |
2279+ DeclNameFlag::AllowLowercaseAndUppercaseSelf);
22712280
22722281 SmallVector<TypeRepr*, 8 > args;
22732282 SourceLoc LAngleLoc, RAngleLoc;
@@ -3123,8 +3132,10 @@ ParserStatus Parser::parseExprList(tok leftTok, tok rightTok,
31233132 Expr *SubExpr = nullptr ;
31243133 if (isUnappliedOperator ()) {
31253134 DeclNameLoc Loc;
3126- auto OperName = parseDeclNameRef (Loc, diag::expected_operator_ref,
3127- DeclNameFlag::AllowOperators);
3135+ auto OperName =
3136+ parseDeclNameRef (Loc, diag::expected_operator_ref,
3137+ DeclNameFlag::AllowOperators |
3138+ DeclNameFlag::AllowLowercaseAndUppercaseSelf);
31283139 if (!OperName) {
31293140 return makeParserError ();
31303141 }
0 commit comments