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