@@ -10287,8 +10287,9 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10287
10287
// designated protocol. These both look like identifiers, so we
10288
10288
// parse them both as identifiers here and sort it out in type
10289
10289
// checking.
10290
- SourceLoc colonLoc, groupLoc;
10291
- Identifier groupName;
10290
+ SourceLoc colonLoc;
10291
+ DeclNameLoc groupLoc;
10292
+ DeclNameRef groupName;
10292
10293
if (Tok.is (tok::colon)) {
10293
10294
colonLoc = consumeToken ();
10294
10295
if (Tok.is (tok::code_complete)) {
@@ -10301,9 +10302,9 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10301
10302
return makeParserCodeCompletionResult<OperatorDecl>();
10302
10303
}
10303
10304
10304
- ( void ) parseIdentifier ( groupName, groupLoc,
10305
- diag::operator_decl_expected_precedencegroup,
10306
- /* diagnoseDollarPrefix= */ false );
10305
+ groupName = parseDeclNameRef ( groupLoc,
10306
+ diag::operator_decl_expected_precedencegroup,
10307
+ {} );
10307
10308
10308
10309
if (Context.TypeCheckerOpts .EnableOperatorDesignatedTypes ) {
10309
10310
// Designated types have been removed; consume the list (mainly for source
@@ -10318,7 +10319,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10318
10319
// These have no precedence group, so we already parsed the first entry
10319
10320
// in the designated types list. Retroactively include it in the range.
10320
10321
typesStartLoc = colonLoc;
10321
- typesEndLoc = groupLoc;
10322
+ typesEndLoc = groupLoc. getEndLoc () ;
10322
10323
}
10323
10324
10324
10325
while (Tok.isNot (tok::eof)) {
@@ -10337,7 +10338,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10337
10338
} else {
10338
10339
if (isPrefix || isPostfix) {
10339
10340
// If we have nothing after the colon, then just remove the colon.
10340
- auto endLoc = groupLoc.isValid () ? groupLoc : colonLoc;
10341
+ auto endLoc = groupLoc.isValid () ? groupLoc. getEndLoc () : colonLoc;
10341
10342
diagnose (colonLoc, diag::precedencegroup_not_infix)
10342
10343
.fixItRemove ({colonLoc, endLoc});
10343
10344
}
@@ -10348,14 +10349,14 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10348
10349
}
10349
10350
10350
10351
// Diagnose deprecated operator body syntax `operator + { ... }`.
10352
+ SourceLoc lastGoodLoc = PreviousLoc;
10351
10353
SourceLoc lBraceLoc;
10352
10354
if (consumeIf (tok::l_brace, lBraceLoc)) {
10353
10355
if (isInfix && !Tok.is (tok::r_brace)) {
10354
10356
diagnose (lBraceLoc, diag::deprecated_operator_body_use_group);
10355
10357
} else {
10356
10358
auto Diag = diagnose (lBraceLoc, diag::deprecated_operator_body);
10357
10359
if (Tok.is (tok::r_brace)) {
10358
- SourceLoc lastGoodLoc = groupLoc.isValid () ? groupLoc : NameLoc;
10359
10360
SourceLoc lastGoodLocEnd = Lexer::getLocForEndOfToken (SourceMgr,
10360
10361
lastGoodLoc);
10361
10362
SourceLoc rBraceEnd = Lexer::getLocForEndOfToken (SourceMgr, Tok.getLoc ());
@@ -10377,7 +10378,8 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
10377
10378
else
10378
10379
res = new (Context)
10379
10380
InfixOperatorDecl (CurDeclContext, OperatorLoc, Name, NameLoc, colonLoc,
10380
- groupName, groupLoc);
10381
+ groupName.getBaseIdentifier (),
10382
+ groupLoc.getBaseNameLoc ());
10381
10383
10382
10384
diagnoseOperatorFixityAttributes (*this , Attributes, res);
10383
10385
@@ -10596,14 +10598,16 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
10596
10598
return abortBody (/* hasCodeCompletion*/ true );
10597
10599
}
10598
10600
10599
- if (Tok.isNot (tok::identifier)) {
10600
- diagnose (Tok, diag::expected_precedencegroup_relation, attrName);
10601
+ DeclNameLoc nameLoc;
10602
+ auto name = parseDeclNameRef (nameLoc,
10603
+ { diag::expected_precedencegroup_relation,
10604
+ attrName },
10605
+ {});
10606
+ if (!name) {
10601
10607
return abortBody ();
10602
10608
}
10603
- Identifier name;
10604
- SourceLoc nameLoc = consumeIdentifier (name,
10605
- /* diagnoseDollarPrefix=*/ false );
10606
- relations.push_back ({nameLoc, name, nullptr });
10609
+ relations.push_back ({nameLoc.getBaseNameLoc (), name.getBaseIdentifier (),
10610
+ nullptr });
10607
10611
10608
10612
if (skipUnspacedCodeCompleteToken ())
10609
10613
return abortBody (/* hasCodeCompletion*/ true );
0 commit comments