@@ -841,7 +841,7 @@ Parser::parseTypeSimpleOrComposition(Diag<> MessageID,
841841 // This is only semantically allowed in certain contexts, but we parse it
842842 // generally for diagnostics and recovery.
843843 SourceLoc opaqueLoc;
844- if (Tok.is (tok::identifier) && Tok. getRawText () == " some" ) {
844+ if (Tok.isContextualKeyword ( " some" ) ) {
845845 // Treat some as a keyword.
846846 TokReceiver->registerTokenKindChange (Tok.getLoc (), tok::contextual_keyword);
847847 opaqueLoc = consumeToken ();
@@ -905,7 +905,7 @@ Parser::parseTypeSimpleOrComposition(Diag<> MessageID,
905905 }
906906
907907 // Diagnose invalid `some` after an ampersand.
908- if (Tok.is (tok::identifier) && Tok. getRawText () == " some" ) {
908+ if (Tok.isContextualKeyword ( " some" ) ) {
909909 auto badLoc = consumeToken ();
910910
911911 diagnose (badLoc, diag::opaque_mid_composition)
@@ -1094,7 +1094,7 @@ ParserResult<TypeRepr> Parser::parseTypeTupleBody() {
10941094 // If the label is "some", this could end up being an opaque type
10951095 // description if there's `some <identifier>` without a following colon,
10961096 // so we may need to backtrack as well.
1097- if (Tok.getText (). equals (" some" )) {
1097+ if (Tok.isContextualKeyword (" some" )) {
10981098 Backtracking.emplace (*this );
10991099 }
11001100
@@ -1531,6 +1531,9 @@ bool Parser::canParseType() {
15311531 // Accept 'inout' at for better recovery.
15321532 consumeIf (tok::kw_inout);
15331533
1534+ if (Tok.isContextualKeyword (" some" ))
1535+ consumeToken ();
1536+
15341537 switch (Tok.getKind ()) {
15351538 case tok::kw_Self:
15361539 case tok::kw_Any:
0 commit comments