@@ -10330,8 +10330,9 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
1033010330 // designated protocol. These both look like identifiers, so we
1033110331 // parse them both as identifiers here and sort it out in type
1033210332 // checking.
10333- SourceLoc colonLoc, groupLoc;
10334- Identifier groupName;
10333+ SourceLoc colonLoc;
10334+ DeclNameLoc groupLoc;
10335+ DeclNameRef groupName;
1033510336 if (Tok.is (tok::colon)) {
1033610337 colonLoc = consumeToken ();
1033710338 if (Tok.is (tok::code_complete)) {
@@ -10344,9 +10345,9 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
1034410345 return makeParserCodeCompletionResult<OperatorDecl>();
1034510346 }
1034610347
10347- ( void ) parseIdentifier ( groupName, groupLoc,
10348- diag::operator_decl_expected_precedencegroup,
10349- /* diagnoseDollarPrefix= */ false );
10348+ groupName = parseDeclNameRef ( groupLoc,
10349+ diag::operator_decl_expected_precedencegroup,
10350+ {} );
1035010351
1035110352 if (Context.TypeCheckerOpts .EnableOperatorDesignatedTypes ) {
1035210353 // Designated types have been removed; consume the list (mainly for source
@@ -10361,7 +10362,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
1036110362 // These have no precedence group, so we already parsed the first entry
1036210363 // in the designated types list. Retroactively include it in the range.
1036310364 typesStartLoc = colonLoc;
10364- typesEndLoc = groupLoc;
10365+ typesEndLoc = groupLoc. getEndLoc () ;
1036510366 }
1036610367
1036710368 while (Tok.isNot (tok::eof)) {
@@ -10380,7 +10381,7 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
1038010381 } else {
1038110382 if (isPrefix || isPostfix) {
1038210383 // If we have nothing after the colon, then just remove the colon.
10383- auto endLoc = groupLoc.isValid () ? groupLoc : colonLoc;
10384+ auto endLoc = groupLoc.isValid () ? groupLoc. getEndLoc () : colonLoc;
1038410385 diagnose (colonLoc, diag::precedencegroup_not_infix)
1038510386 .fixItRemove ({colonLoc, endLoc});
1038610387 }
@@ -10391,14 +10392,14 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
1039110392 }
1039210393
1039310394 // Diagnose deprecated operator body syntax `operator + { ... }`.
10395+ SourceLoc lastGoodLoc = PreviousLoc;
1039410396 SourceLoc lBraceLoc;
1039510397 if (consumeIf (tok::l_brace, lBraceLoc)) {
1039610398 if (isInfix && !Tok.is (tok::r_brace)) {
1039710399 diagnose (lBraceLoc, diag::deprecated_operator_body_use_group);
1039810400 } else {
1039910401 auto Diag = diagnose (lBraceLoc, diag::deprecated_operator_body);
1040010402 if (Tok.is (tok::r_brace)) {
10401- SourceLoc lastGoodLoc = groupLoc.isValid () ? groupLoc : NameLoc;
1040210403 SourceLoc lastGoodLocEnd = Lexer::getLocForEndOfToken (SourceMgr,
1040310404 lastGoodLoc);
1040410405 SourceLoc rBraceEnd = Lexer::getLocForEndOfToken (SourceMgr, Tok.getLoc ());
@@ -10420,7 +10421,8 @@ Parser::parseDeclOperatorImpl(SourceLoc OperatorLoc, Identifier Name,
1042010421 else
1042110422 res = new (Context)
1042210423 InfixOperatorDecl (CurDeclContext, OperatorLoc, Name, NameLoc, colonLoc,
10423- groupName, groupLoc);
10424+ groupName.getBaseIdentifier (),
10425+ groupLoc.getBaseNameLoc ());
1042410426
1042510427 diagnoseOperatorFixityAttributes (*this , Attributes, res);
1042610428
@@ -10639,14 +10641,16 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
1063910641 return abortBody (/* hasCodeCompletion*/ true );
1064010642 }
1064110643
10642- if (Tok.isNot (tok::identifier)) {
10643- diagnose (Tok, diag::expected_precedencegroup_relation, attrName);
10644+ DeclNameLoc nameLoc;
10645+ auto name = parseDeclNameRef (nameLoc,
10646+ { diag::expected_precedencegroup_relation,
10647+ attrName },
10648+ {});
10649+ if (!name) {
1064410650 return abortBody ();
1064510651 }
10646- Identifier name;
10647- SourceLoc nameLoc = consumeIdentifier (name,
10648- /* diagnoseDollarPrefix=*/ false );
10649- relations.push_back ({nameLoc, name, nullptr });
10652+ relations.push_back ({nameLoc.getBaseNameLoc (), name.getBaseIdentifier (),
10653+ nullptr });
1065010654
1065110655 if (skipUnspacedCodeCompleteToken ())
1065210656 return abortBody (/* hasCodeCompletion*/ true );
0 commit comments