@@ -10108,8 +10108,9 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10108
10108
// designated protocol. These both look like identifiers, so we
10109
10109
// parse them both as identifiers here and sort it out in type
10110
10110
// checking.
10111
- SourceLoc colonLoc, groupLoc;
10112
- Identifier groupName;
10111
+ SourceLoc colonLoc;
10112
+ DeclNameLoc groupLoc;
10113
+ DeclNameRef groupName;
10113
10114
if (Tok.is (tok::colon)) {
10114
10115
colonLoc = consumeToken ();
10115
10116
if (Tok.is (tok::code_complete)) {
@@ -10122,9 +10123,9 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10122
10123
return makeParserCodeCompletionResult<OperatorDecl>();
10123
10124
}
10124
10125
10125
- ( void ) parseIdentifier ( groupName, groupLoc,
10126
- diag::operator_decl_expected_precedencegroup,
10127
- /* diagnoseDollarPrefix= */ false );
10126
+ groupName = parseDeclNameRef ( groupLoc,
10127
+ diag::operator_decl_expected_precedencegroup,
10128
+ {} );
10128
10129
10129
10130
if (Context.TypeCheckerOpts .EnableOperatorDesignatedTypes ) {
10130
10131
// Designated types have been removed; consume the list (mainly for source
@@ -10139,7 +10140,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10139
10140
// These have no precedence group, so we already parsed the first entry
10140
10141
// in the designated types list. Retroactively include it in the range.
10141
10142
typesStartLoc = colonLoc;
10142
- typesEndLoc = groupLoc;
10143
+ typesEndLoc = groupLoc. getEndLoc () ;
10143
10144
}
10144
10145
10145
10146
while (Tok.isNot (tok::eof)) {
@@ -10158,7 +10159,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10158
10159
} else {
10159
10160
if (isPrefix || isPostfix) {
10160
10161
// If we have nothing after the colon, then just remove the colon.
10161
- auto endLoc = groupLoc.isValid () ? groupLoc : colonLoc;
10162
+ auto endLoc = groupLoc.isValid () ? groupLoc. getEndLoc () : colonLoc;
10162
10163
diagnose (colonLoc, diag::precedencegroup_not_infix)
10163
10164
.fixItRemove ({colonLoc, endLoc});
10164
10165
}
@@ -10169,14 +10170,14 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10169
10170
}
10170
10171
10171
10172
// Diagnose deprecated operator body syntax `operator + { ... }`.
10173
+ SourceLoc lastGoodLoc = PreviousLoc;
10172
10174
SourceLoc lBraceLoc;
10173
10175
if (consumeIf (tok::l_brace, lBraceLoc)) {
10174
10176
if (isInfix && !Tok.is (tok::r_brace)) {
10175
10177
diagnose (lBraceLoc, diag::deprecated_operator_body_use_group);
10176
10178
} else {
10177
10179
auto Diag = diagnose (lBraceLoc, diag::deprecated_operator_body);
10178
10180
if (Tok.is (tok::r_brace)) {
10179
- SourceLoc lastGoodLoc = groupLoc.isValid () ? groupLoc : NameLoc;
10180
10181
SourceLoc lastGoodLocEnd = Lexer::getLocForEndOfToken (SourceMgr,
10181
10182
lastGoodLoc);
10182
10183
SourceLoc rBraceEnd = Lexer::getLocForEndOfToken (SourceMgr, Tok.getLoc ());
@@ -10198,7 +10199,8 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10198
10199
else
10199
10200
res = new (Context)
10200
10201
InfixOperatorDecl (CurDeclContext, OperatorLoc, Name, NameLoc, colonLoc,
10201
- groupName, groupLoc);
10202
+ groupName.getBaseIdentifier (),
10203
+ groupLoc.getBaseNameLoc ());
10202
10204
10203
10205
diagnoseOperatorFixityAttributes (*this , Attributes, res);
10204
10206
@@ -10417,14 +10419,16 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
10417
10419
return abortBody (/* hasCodeCompletion*/ true );
10418
10420
}
10419
10421
10420
- if (Tok.isNot (tok::identifier)) {
10421
- diagnose (Tok, diag::expected_precedencegroup_relation, attrName);
10422
+ DeclNameLoc nameLoc;
10423
+ auto name = parseDeclNameRef (nameLoc,
10424
+ { diag::expected_precedencegroup_relation,
10425
+ attrName },
10426
+ {});
10427
+ if (!name) {
10422
10428
return abortBody ();
10423
10429
}
10424
- Identifier name;
10425
- SourceLoc nameLoc = consumeIdentifier (name,
10426
- /* diagnoseDollarPrefix=*/ false );
10427
- relations.push_back ({nameLoc, name, nullptr });
10430
+ relations.push_back ({nameLoc.getBaseNameLoc (), name.getBaseIdentifier (),
10431
+ nullptr });
10428
10432
10429
10433
if (skipUnspacedCodeCompleteToken ())
10430
10434
return abortBody (/* hasCodeCompletion*/ true );
0 commit comments