@@ -1209,6 +1209,17 @@ class ImportDecl final : public Decl,
12091209 }
12101210};
12111211
1212+ // / An entry in the "inherited" list of a type or extension.
1213+ struct InheritedEntry : public TypeLoc {
1214+ // / Whether there was an @unchecked attribute.
1215+ bool isUnchecked = false ;
1216+
1217+ InheritedEntry (const TypeLoc &typeLoc);
1218+
1219+ InheritedEntry (const TypeLoc &typeLoc, bool isUnchecked)
1220+ : TypeLoc(typeLoc), isUnchecked(isUnchecked) { }
1221+ };
1222+
12121223// / ExtensionDecl - This represents a type extension containing methods
12131224// / associated with the type. This is not a ValueDecl and has no Type because
12141225// / there are no runtime values of the Extension's type.
@@ -1227,7 +1238,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
12271238 // / extended nominal.
12281239 llvm::PointerIntPair<NominalTypeDecl *, 1 , bool > ExtendedNominal;
12291240
1230- ArrayRef<TypeLoc > Inherited;
1241+ ArrayRef<InheritedEntry > Inherited;
12311242
12321243 // / The next extension in the linked list of extensions.
12331244 // /
@@ -1246,7 +1257,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
12461257 friend class IterableDeclContext ;
12471258
12481259 ExtensionDecl (SourceLoc extensionLoc, TypeRepr *extendedType,
1249- ArrayRef<TypeLoc > inherited,
1260+ ArrayRef<InheritedEntry > inherited,
12501261 DeclContext *parent,
12511262 TrailingWhereClause *trailingWhereClause);
12521263
@@ -1271,7 +1282,7 @@ class ExtensionDecl final : public GenericContext, public Decl,
12711282 // / Create a new extension declaration.
12721283 static ExtensionDecl *create (ASTContext &ctx, SourceLoc extensionLoc,
12731284 TypeRepr *extendedType,
1274- ArrayRef<TypeLoc > inherited,
1285+ ArrayRef<InheritedEntry > inherited,
12751286 DeclContext *parent,
12761287 TrailingWhereClause *trailingWhereClause,
12771288 ClangNode clangNode = ClangNode());
@@ -1326,9 +1337,9 @@ class ExtensionDecl final : public GenericContext, public Decl,
13261337
13271338 // / Retrieve the set of protocols that this type inherits (i.e,
13281339 // / explicitly conforms to).
1329- ArrayRef<TypeLoc > getInherited () const { return Inherited; }
1340+ ArrayRef<InheritedEntry > getInherited () const { return Inherited; }
13301341
1331- void setInherited (ArrayRef<TypeLoc > i) { Inherited = i; }
1342+ void setInherited (ArrayRef<InheritedEntry > i) { Inherited = i; }
13321343
13331344 bool hasDefaultAccessLevel () const {
13341345 return Bits.ExtensionDecl .DefaultAndMaxAccessLevel != 0 ;
@@ -2538,12 +2549,12 @@ class ValueDecl : public Decl {
25382549
25392550// / This is a common base class for declarations which declare a type.
25402551class TypeDecl : public ValueDecl {
2541- ArrayRef<TypeLoc > Inherited;
2552+ ArrayRef<InheritedEntry > Inherited;
25422553
25432554protected:
25442555 TypeDecl (DeclKind K, llvm::PointerUnion<DeclContext *, ASTContext *> context,
25452556 Identifier name, SourceLoc NameLoc,
2546- ArrayRef<TypeLoc > inherited) :
2557+ ArrayRef<InheritedEntry > inherited) :
25472558 ValueDecl (K, context, name, NameLoc), Inherited(inherited) {}
25482559
25492560public:
@@ -2561,9 +2572,9 @@ class TypeDecl : public ValueDecl {
25612572
25622573 // / Retrieve the set of protocols that this type inherits (i.e,
25632574 // / explicitly conforms to).
2564- ArrayRef<TypeLoc > getInherited () const { return Inherited; }
2575+ ArrayRef<InheritedEntry > getInherited () const { return Inherited; }
25652576
2566- void setInherited (ArrayRef<TypeLoc > i) { Inherited = i; }
2577+ void setInherited (ArrayRef<InheritedEntry > i) { Inherited = i; }
25672578
25682579 static bool classof (const Decl *D) {
25692580 return D->getKind () >= DeclKind::First_TypeDecl &&
@@ -2588,7 +2599,7 @@ class GenericTypeDecl : public GenericContext, public TypeDecl {
25882599public:
25892600 GenericTypeDecl (DeclKind K, DeclContext *DC,
25902601 Identifier name, SourceLoc nameLoc,
2591- ArrayRef<TypeLoc > inherited,
2602+ ArrayRef<InheritedEntry > inherited,
25922603 GenericParamList *GenericParams);
25932604
25942605 // Resolve ambiguity due to multiple base classes.
@@ -3115,7 +3126,7 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
31153126
31163127 NominalTypeDecl (DeclKind K, DeclContext *DC, Identifier name,
31173128 SourceLoc NameLoc,
3118- ArrayRef<TypeLoc > inherited,
3129+ ArrayRef<InheritedEntry > inherited,
31193130 GenericParamList *GenericParams) :
31203131 GenericTypeDecl (K, DC, name, NameLoc, inherited, GenericParams),
31213132 IterableDeclContext (IterableDeclContextKind::NominalTypeDecl)
@@ -3411,7 +3422,7 @@ class EnumDecl final : public NominalTypeDecl {
34113422
34123423public:
34133424 EnumDecl (SourceLoc EnumLoc, Identifier Name, SourceLoc NameLoc,
3414- ArrayRef<TypeLoc > Inherited,
3425+ ArrayRef<InheritedEntry > Inherited,
34153426 GenericParamList *GenericParams, DeclContext *DC);
34163427
34173428 SourceLoc getStartLoc () const { return EnumLoc; }
@@ -3579,7 +3590,7 @@ class StructDecl final : public NominalTypeDecl {
35793590
35803591public:
35813592 StructDecl (SourceLoc StructLoc, Identifier Name, SourceLoc NameLoc,
3582- ArrayRef<TypeLoc > Inherited,
3593+ ArrayRef<InheritedEntry > Inherited,
35833594 GenericParamList *GenericParams, DeclContext *DC);
35843595
35853596 SourceLoc getStartLoc () const { return StructLoc; }
@@ -3725,7 +3736,7 @@ class ClassDecl final : public NominalTypeDecl {
37253736
37263737public:
37273738 ClassDecl (SourceLoc ClassLoc, Identifier Name, SourceLoc NameLoc,
3728- ArrayRef<TypeLoc > Inherited,
3739+ ArrayRef<InheritedEntry > Inherited,
37293740 GenericParamList *GenericParams, DeclContext *DC,
37303741 bool isActor);
37313742
@@ -4160,7 +4171,7 @@ class ProtocolDecl final : public NominalTypeDecl {
41604171
41614172public:
41624173 ProtocolDecl (DeclContext *DC, SourceLoc ProtocolLoc, SourceLoc NameLoc,
4163- Identifier Name, ArrayRef<TypeLoc > Inherited,
4174+ Identifier Name, ArrayRef<InheritedEntry > Inherited,
41644175 TrailingWhereClause *TrailingWhere);
41654176
41664177 using Decl::getASTContext;
0 commit comments