@@ -6380,18 +6380,17 @@ class OperatorDecl : public Decl {
6380
6380
6381
6381
Identifier name;
6382
6382
6383
- Identifier DesignatedNominalTypeName ;
6384
- SourceLoc DesignatedNominalTypeNameLoc ;
6383
+ ArrayRef< Identifier> Identifiers ;
6384
+ ArrayRef< SourceLoc> IdentifierLocs ;
6385
6385
NominalTypeDecl *DesignatedNominalType = nullptr ;
6386
6386
6387
6387
public:
6388
6388
OperatorDecl (DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,
6389
6389
Identifier Name, SourceLoc NameLoc,
6390
- Identifier DesignatedNominalTypeName = Identifier() ,
6391
- SourceLoc DesignatedNominalTypeNameLoc = SourceLoc() )
6390
+ ArrayRef< Identifier> Identifiers ,
6391
+ ArrayRef< SourceLoc> IdentifierLocs )
6392
6392
: Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name),
6393
- DesignatedNominalTypeName (DesignatedNominalTypeName),
6394
- DesignatedNominalTypeNameLoc(DesignatedNominalTypeNameLoc) {}
6393
+ Identifiers (Identifiers), IdentifierLocs(IdentifierLocs) {}
6395
6394
6396
6395
OperatorDecl (DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,
6397
6396
Identifier Name, SourceLoc NameLoc,
@@ -6405,12 +6404,20 @@ class OperatorDecl : public Decl {
6405
6404
SourceLoc getNameLoc () const { return NameLoc; }
6406
6405
Identifier getName () const { return name; }
6407
6406
6407
+ ArrayRef<Identifier> getIdentifiers () const {
6408
+ return Identifiers;
6409
+ }
6410
+
6411
+ ArrayRef<SourceLoc> getIdentifierLocs () const {
6412
+ return IdentifierLocs;
6413
+ }
6414
+
6408
6415
Identifier getDesignatedNominalTypeName () const {
6409
- return DesignatedNominalTypeName ;
6416
+ return !Identifiers. empty () ? Identifiers[ 0 ] : Identifier () ;
6410
6417
}
6411
6418
6412
6419
SourceLoc getDesignatedNominalTypeNameLoc () const {
6413
- return DesignatedNominalTypeNameLoc ;
6420
+ return !IdentifierLocs. empty () ? IdentifierLocs[ 0 ] : SourceLoc () ;
6414
6421
}
6415
6422
6416
6423
NominalTypeDecl *getDesignatedNominalType () const {
@@ -6436,20 +6443,17 @@ class OperatorDecl : public Decl {
6436
6443
// / infix operator /+/ : AdditionPrecedence, Numeric
6437
6444
// / \endcode
6438
6445
class InfixOperatorDecl : public OperatorDecl {
6439
- SourceLoc ColonLoc, FirstIdentifierLoc, SecondIdentifierLoc;
6440
- Identifier FirstIdentifier, SecondIdentifier;
6446
+ SourceLoc ColonLoc;
6441
6447
PrecedenceGroupDecl *PrecedenceGroup = nullptr ;
6442
6448
6443
6449
public:
6444
6450
InfixOperatorDecl (DeclContext *DC, SourceLoc operatorLoc, Identifier name,
6445
6451
SourceLoc nameLoc, SourceLoc colonLoc,
6446
- Identifier firstIdentifier, SourceLoc firstIdentifierLoc,
6447
- Identifier secondIdentifier = Identifier(),
6448
- SourceLoc secondIdentifierLoc = SourceLoc())
6449
- : OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc),
6450
- ColonLoc (colonLoc), FirstIdentifierLoc(firstIdentifierLoc),
6451
- SecondIdentifierLoc(secondIdentifierLoc),
6452
- FirstIdentifier(firstIdentifier), SecondIdentifier(secondIdentifier) {}
6452
+ ArrayRef<Identifier> identifiers,
6453
+ ArrayRef<SourceLoc> identifierLocs)
6454
+ : OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc,
6455
+ identifiers, identifierLocs),
6456
+ ColonLoc (colonLoc) {}
6453
6457
6454
6458
InfixOperatorDecl (DeclContext *DC, SourceLoc operatorLoc, Identifier name,
6455
6459
SourceLoc nameLoc, SourceLoc colonLoc,
@@ -6460,22 +6464,34 @@ class InfixOperatorDecl : public OperatorDecl {
6460
6464
ColonLoc(colonLoc), PrecedenceGroup(precedenceGroup) {}
6461
6465
6462
6466
SourceLoc getEndLoc () const {
6463
- if (!SecondIdentifier .empty ())
6464
- return SecondIdentifierLoc ;
6465
- if (!FirstIdentifier .empty ())
6466
- return FirstIdentifierLoc ;
6467
+ if (!getSecondIdentifier () .empty ())
6468
+ return getSecondIdentifierLoc () ;
6469
+ if (!getFirstIdentifier () .empty ())
6470
+ return getFirstIdentifierLoc () ;
6467
6471
return getNameLoc ();
6468
6472
}
6469
6473
SourceRange getSourceRange () const {
6470
6474
return { getOperatorLoc (), getEndLoc () };
6471
6475
}
6472
6476
6473
6477
SourceLoc getColonLoc () const { return ColonLoc; }
6474
- SourceLoc getFirstIdentifierLoc () const { return FirstIdentifierLoc; }
6475
- SourceLoc getSecondIdentifierLoc () const { return SecondIdentifierLoc; }
6478
+ SourceLoc getFirstIdentifierLoc () const {
6479
+ auto identifierLocs = getIdentifierLocs ();
6480
+ return !identifierLocs.empty () ? identifierLocs[0 ] : SourceLoc ();
6481
+ }
6482
+ SourceLoc getSecondIdentifierLoc () const {
6483
+ auto identifierLocs = getIdentifierLocs ();
6484
+ return identifierLocs.size () > 1 ? identifierLocs[1 ] : SourceLoc ();
6485
+ }
6476
6486
6477
- Identifier getFirstIdentifier () const { return FirstIdentifier; }
6478
- Identifier getSecondIdentifier () const { return SecondIdentifier; }
6487
+ Identifier getFirstIdentifier () const {
6488
+ auto identifiers = getIdentifiers ();
6489
+ return !identifiers.empty () ? identifiers[0 ] : Identifier ();
6490
+ }
6491
+ Identifier getSecondIdentifier () const {
6492
+ auto identifiers = getIdentifiers ();
6493
+ return identifiers.size () > 1 ? identifiers[1 ] : Identifier ();
6494
+ }
6479
6495
6480
6496
PrecedenceGroupDecl *getPrecedenceGroup () const { return PrecedenceGroup; }
6481
6497
void setPrecedenceGroup (PrecedenceGroupDecl *PGD) {
@@ -6502,10 +6518,10 @@ class PrefixOperatorDecl : public OperatorDecl {
6502
6518
public:
6503
6519
PrefixOperatorDecl (DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
6504
6520
SourceLoc NameLoc,
6505
- Identifier DesignatedNominalTypeName = Identifier() ,
6506
- SourceLoc DesignatedNominalTypeNameLoc = SourceLoc() )
6521
+ ArrayRef< Identifier> Identifiers ,
6522
+ ArrayRef< SourceLoc> IdentifierLocs )
6507
6523
: OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc,
6508
- DesignatedNominalTypeName, DesignatedNominalTypeNameLoc ) {}
6524
+ Identifiers, IdentifierLocs ) {}
6509
6525
6510
6526
PrefixOperatorDecl (DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
6511
6527
SourceLoc NameLoc, NominalTypeDecl *DesignatedNominalType)
@@ -6536,10 +6552,10 @@ class PostfixOperatorDecl : public OperatorDecl {
6536
6552
public:
6537
6553
PostfixOperatorDecl (DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
6538
6554
SourceLoc NameLoc,
6539
- Identifier DesignatedNominalTypeName = Identifier() ,
6540
- SourceLoc DesignatedNominalTypeNameLoc = SourceLoc() )
6555
+ ArrayRef< Identifier> Identifiers ,
6556
+ ArrayRef< SourceLoc> IdentifierLocs )
6541
6557
: OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc,
6542
- DesignatedNominalTypeName, DesignatedNominalTypeNameLoc ) {}
6558
+ Identifiers, IdentifierLocs ) {}
6543
6559
6544
6560
PostfixOperatorDecl (DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
6545
6561
SourceLoc NameLoc, NominalTypeDecl *DesignatedNominalType)
0 commit comments