@@ -493,7 +493,7 @@ class alignas(1 << DeclAlignInBits) Decl {
493
493
HasLazyConformances : 1
494
494
);
495
495
496
- SWIFT_INLINE_BITFIELD_FULL (ProtocolDecl, NominalTypeDecl, 1 +1 +1 +1 +1 +1 +1 +2 +8 +16 ,
496
+ SWIFT_INLINE_BITFIELD_FULL (ProtocolDecl, NominalTypeDecl, 1 +1 +1 +1 +1 +1 +1 +2 +1 + 8 +16 ,
497
497
// / Whether the \c RequiresClass bit is valid.
498
498
RequiresClassValid : 1 ,
499
499
@@ -519,6 +519,9 @@ class alignas(1 << DeclAlignInBits) Decl {
519
519
// / The stage of the circularity check for this protocol.
520
520
Circularity : 2 ,
521
521
522
+ // / Whether we've computed the inherited protocols list yet.
523
+ InheritedProtocolsValid : 1 ,
524
+
522
525
: NumPadBits,
523
526
524
527
// / If this is a compiler-known protocol, this will be a KnownProtocolKind
@@ -3893,15 +3896,7 @@ struct SelfReferenceKind {
3893
3896
class ProtocolDecl final : public NominalTypeDecl {
3894
3897
SourceLoc ProtocolLoc;
3895
3898
3896
- // / The generic signature representing exactly the new requirements introduced
3897
- // / by this protocol.
3898
- const Requirement *RequirementSignature = nullptr ;
3899
-
3900
- bool requiresClassSlow ();
3901
-
3902
- bool existentialConformsToSelfSlow ();
3903
-
3904
- bool existentialTypeSupportedSlow (LazyResolver *resolver);
3899
+ ArrayRef<ProtocolDecl *> InheritedProtocols;
3905
3900
3906
3901
struct {
3907
3902
// / The superclass decl and a bit to indicate whether the
@@ -3913,6 +3908,18 @@ class ProtocolDecl final : public NominalTypeDecl {
3913
3908
llvm::PointerIntPair<Type, 1 , bool > SuperclassType;
3914
3909
} LazySemanticInfo;
3915
3910
3911
+ // / The generic signature representing exactly the new requirements introduced
3912
+ // / by this protocol.
3913
+ const Requirement *RequirementSignature = nullptr ;
3914
+
3915
+ bool requiresClassSlow ();
3916
+
3917
+ bool existentialConformsToSelfSlow ();
3918
+
3919
+ bool existentialTypeSupportedSlow (LazyResolver *resolver);
3920
+
3921
+ ArrayRef<ProtocolDecl *> getInheritedProtocolsSlow ();
3922
+
3916
3923
friend class SuperclassDeclRequest ;
3917
3924
friend class SuperclassTypeRequest ;
3918
3925
friend class TypeChecker ;
@@ -3925,7 +3932,12 @@ class ProtocolDecl final : public NominalTypeDecl {
3925
3932
using Decl::getASTContext;
3926
3933
3927
3934
// / Retrieve the set of protocols inherited from this protocol.
3928
- llvm::TinyPtrVector<ProtocolDecl *> getInheritedProtocols () const ;
3935
+ ArrayRef<ProtocolDecl *> getInheritedProtocols () const {
3936
+ if (Bits.ProtocolDecl .InheritedProtocolsValid )
3937
+ return InheritedProtocols;
3938
+
3939
+ return const_cast <ProtocolDecl *>(this )->getInheritedProtocolsSlow ();
3940
+ }
3929
3941
3930
3942
// / Determine whether this protocol has a superclass.
3931
3943
bool hasSuperclass () const { return (bool )getSuperclassDecl (); }
0 commit comments