@@ -7276,22 +7276,13 @@ class OperatorDecl : public Decl {
7276
7276
7277
7277
Identifier name;
7278
7278
7279
- ArrayRef<Located<Identifier>> Identifiers;
7280
- ArrayRef<NominalTypeDecl *> DesignatedNominalTypes;
7281
7279
SourceLoc getLocFromSource () const { return NameLoc; }
7282
7280
friend class Decl ;
7283
7281
public:
7284
7282
OperatorDecl (DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,
7285
- Identifier Name, SourceLoc NameLoc,
7286
- ArrayRef<Located<Identifier>> Identifiers)
7287
- : Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name),
7288
- Identifiers (Identifiers) {}
7289
-
7290
- OperatorDecl (DeclKind kind, DeclContext *DC, SourceLoc OperatorLoc,
7291
- Identifier Name, SourceLoc NameLoc,
7292
- ArrayRef<NominalTypeDecl *> DesignatedNominalTypes)
7293
- : Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name),
7294
- DesignatedNominalTypes(DesignatedNominalTypes) {}
7283
+ Identifier Name, SourceLoc NameLoc)
7284
+ : Decl(kind, DC), OperatorLoc(OperatorLoc), NameLoc(NameLoc), name(Name)
7285
+ {}
7295
7286
7296
7287
// / Retrieve the operator's fixity, corresponding to the concrete subclass
7297
7288
// / of the OperatorDecl.
@@ -7318,25 +7309,6 @@ class OperatorDecl : public Decl {
7318
7309
// OperatorDecls.
7319
7310
DeclBaseName getBaseName () const { return name; }
7320
7311
7321
- // / Get the list of identifiers after the colon in the operator declaration.
7322
- // /
7323
- // / This list includes the names of designated types. For infix operators, the
7324
- // / first item in the list is a precedence group instead.
7325
- // /
7326
- // / \todo These two purposes really ought to be in separate properties and the
7327
- // / designated type list should be of TypeReprs instead of Identifiers.
7328
- ArrayRef<Located<Identifier>> getIdentifiers () const {
7329
- return Identifiers;
7330
- }
7331
-
7332
- ArrayRef<NominalTypeDecl *> getDesignatedNominalTypes () const {
7333
- return DesignatedNominalTypes;
7334
- }
7335
-
7336
- void setDesignatedNominalTypes (ArrayRef<NominalTypeDecl *> nominalTypes) {
7337
- DesignatedNominalTypes = nominalTypes;
7338
- }
7339
-
7340
7312
static bool classof (const Decl *D) {
7341
7313
// Workaround: http://llvm.org/PR35906
7342
7314
if (DeclKind::Last_Decl == DeclKind::Last_OperatorDecl)
@@ -7352,22 +7324,23 @@ class OperatorDecl : public Decl {
7352
7324
// / infix operator /+/ : AdditionPrecedence, Numeric
7353
7325
// / \endcode
7354
7326
class InfixOperatorDecl : public OperatorDecl {
7355
- SourceLoc ColonLoc;
7327
+ SourceLoc ColonLoc, PrecedenceGroupLoc;
7328
+ Identifier PrecedenceGroupName;
7356
7329
7357
7330
public:
7358
7331
InfixOperatorDecl (DeclContext *DC, SourceLoc operatorLoc, Identifier name,
7359
7332
SourceLoc nameLoc, SourceLoc colonLoc,
7360
- ArrayRef<Located<Identifier>> identifiers)
7361
- : OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc,
7362
- identifiers),
7363
- ColonLoc (colonLoc) {}
7333
+ Identifier precedenceGroupName,
7334
+ SourceLoc precedenceGroupLoc)
7335
+ : OperatorDecl(DeclKind::InfixOperator, DC, operatorLoc, name, nameLoc),
7336
+ ColonLoc (colonLoc), PrecedenceGroupLoc(precedenceGroupLoc),
7337
+ PrecedenceGroupName(precedenceGroupName) {}
7364
7338
7365
7339
SourceLoc getEndLoc () const {
7366
- auto identifiers = getIdentifiers ();
7367
- if (identifiers.empty ())
7368
- return getNameLoc ();
7340
+ if (getPrecedenceGroupLoc ().isValid ())
7341
+ return getPrecedenceGroupLoc ();
7369
7342
7370
- return identifiers. back (). Loc ;
7343
+ return getNameLoc () ;
7371
7344
}
7372
7345
7373
7346
SourceRange getSourceRange () const {
@@ -7376,6 +7349,8 @@ class InfixOperatorDecl : public OperatorDecl {
7376
7349
7377
7350
SourceLoc getColonLoc () const { return ColonLoc; }
7378
7351
7352
+ Identifier getPrecedenceGroupName () const { return PrecedenceGroupName; }
7353
+ SourceLoc getPrecedenceGroupLoc () const { return PrecedenceGroupLoc; }
7379
7354
PrecedenceGroupDecl *getPrecedenceGroup () const ;
7380
7355
7381
7356
static bool classof (const Decl *D) {
@@ -7391,16 +7366,9 @@ class InfixOperatorDecl : public OperatorDecl {
7391
7366
class PrefixOperatorDecl : public OperatorDecl {
7392
7367
public:
7393
7368
PrefixOperatorDecl (DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
7394
- SourceLoc NameLoc,
7395
- ArrayRef<Located<Identifier>> Identifiers)
7396
- : OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc,
7397
- Identifiers) {}
7398
-
7399
- PrefixOperatorDecl (DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
7400
- SourceLoc NameLoc,
7401
- ArrayRef<NominalTypeDecl *> designatedNominalTypes)
7402
- : OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc,
7403
- designatedNominalTypes) {}
7369
+ SourceLoc NameLoc)
7370
+ : OperatorDecl(DeclKind::PrefixOperator, DC, OperatorLoc, Name, NameLoc)
7371
+ {}
7404
7372
7405
7373
SourceRange getSourceRange () const {
7406
7374
return { getOperatorLoc (), getNameLoc () };
@@ -7419,16 +7387,9 @@ class PrefixOperatorDecl : public OperatorDecl {
7419
7387
class PostfixOperatorDecl : public OperatorDecl {
7420
7388
public:
7421
7389
PostfixOperatorDecl (DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
7422
- SourceLoc NameLoc,
7423
- ArrayRef<Located<Identifier>> Identifiers)
7424
- : OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc,
7425
- Identifiers) {}
7426
-
7427
- PostfixOperatorDecl (DeclContext *DC, SourceLoc OperatorLoc, Identifier Name,
7428
- SourceLoc NameLoc,
7429
- ArrayRef<NominalTypeDecl *> designatedNominalTypes)
7430
- : OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc,
7431
- designatedNominalTypes) {}
7390
+ SourceLoc NameLoc)
7391
+ : OperatorDecl(DeclKind::PostfixOperator, DC, OperatorLoc, Name, NameLoc)
7392
+ {}
7432
7393
7433
7394
SourceRange getSourceRange () const {
7434
7395
return { getOperatorLoc (), getNameLoc () };
0 commit comments