@@ -403,10 +403,13 @@ class alignas(1 << DeclAlignInBits) Decl {
403403 SWIFT_INLINE_BITFIELD (SubscriptDecl, VarDecl, 2 ,
404404 StaticSpelling : 2
405405 );
406- SWIFT_INLINE_BITFIELD (AbstractFunctionDecl, ValueDecl, 3 +8 +1 +1 +1 +1 +1 +1 ,
406+ SWIFT_INLINE_BITFIELD (AbstractFunctionDecl, ValueDecl, 3 +2 + 8 +1 +1 +1 +1 +1 +1 ,
407407 // / \see AbstractFunctionDecl::BodyKind
408408 BodyKind : 3 ,
409409
410+ // / \see AbstractFunctionDecl::SILSynthesizeKind
411+ SILSynthesizeKind : 2 ,
412+
410413 // / Import as member status.
411414 IAMStatus : 8 ,
412415
@@ -3367,8 +3370,6 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
33673370 // / for types that are not global actors.
33683371 VarDecl *getGlobalActorInstance () const ;
33693372
3370- bool hasDistributedActorLocalInitializer () const ;
3371-
33723373 // / Whether this type is a global actor, which can be used as an
33733374 // / attribute to decorate declarations for inclusion in the actor-isolated
33743375 // / state denoted by this type.
@@ -5769,6 +5770,15 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
57695770 friend class NeedsNewVTableEntryRequest ;
57705771
57715772public:
5773+ // / records the kind of SILGen-synthesized body this decl represents
5774+ enum class SILSynthesizeKind {
5775+ None,
5776+ MemberwiseInitializer,
5777+ DistributedActorFactory
5778+
5779+ // This enum currently needs to fit in a 2-bit bitfield.
5780+ };
5781+
57725782 enum class BodyKind {
57735783 // / The function did not have a body in the source code file.
57745784 None,
@@ -5788,8 +5798,8 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
57885798 // / Function body is present and type-checked.
57895799 TypeChecked,
57905800
5791- // / This is a memberwise initializer that will be synthesized by SILGen.
5792- MemberwiseInitializer ,
5801+ // Function body will be synthesized by SILGen.
5802+ SILSynthesize ,
57935803
57945804 // / Function body text was deserialized from a .swiftmodule.
57955805 Deserialized
@@ -5889,6 +5899,14 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
58895899 Bits.AbstractFunctionDecl .BodyKind = unsigned (K);
58905900 }
58915901
5902+ void setSILSynthesizeKind (SILSynthesizeKind K) {
5903+ Bits.AbstractFunctionDecl .SILSynthesizeKind = unsigned (K);
5904+ }
5905+
5906+ SILSynthesizeKind getSILSynthesizeKind () const {
5907+ return SILSynthesizeKind (Bits.AbstractFunctionDecl .SILSynthesizeKind );
5908+ }
5909+
58925910public:
58935911 void setHasSingleExpressionBody (bool Has = true ) {
58945912 Bits.AbstractFunctionDecl .HasSingleExpressionBody = Has;
@@ -6065,7 +6083,17 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
60656083 void setIsMemberwiseInitializer () {
60666084 assert (getBodyKind () == BodyKind::None);
60676085 assert (isa<ConstructorDecl>(this ));
6068- setBodyKind (BodyKind::MemberwiseInitializer);
6086+ setBodyKind (BodyKind::SILSynthesize);
6087+ setSILSynthesizeKind (SILSynthesizeKind::MemberwiseInitializer);
6088+ }
6089+
6090+ // / Mark that the body should be filled in to be a factory method for creating
6091+ // / a distributed actor.
6092+ void setDistributedActorFactory () {
6093+ assert (getBodyKind () == BodyKind::None);
6094+ assert (isa<FuncDecl>(this ));
6095+ setBodyKind (BodyKind::SILSynthesize);
6096+ setSILSynthesizeKind (SILSynthesizeKind::DistributedActorFactory);
60696097 }
60706098
60716099 // / Gets the body of this function, stripping the unused portions of #if
@@ -6089,7 +6117,16 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
60896117 }
60906118
60916119 bool isMemberwiseInitializer () const {
6092- return getBodyKind () == BodyKind::MemberwiseInitializer;
6120+ return getBodyKind () == BodyKind::SILSynthesize
6121+ && getSILSynthesizeKind () == SILSynthesizeKind::MemberwiseInitializer;
6122+ }
6123+
6124+ // / Determines whether this function represents a distributed actor
6125+ // / initialization factory. Such functions do not have a body that is
6126+ // / representable in the AST, so it must be synthesized during SILGen.
6127+ bool isDistributedActorFactory () const {
6128+ return getBodyKind () == BodyKind::SILSynthesize
6129+ && getSILSynthesizeKind () == SILSynthesizeKind::DistributedActorFactory;
60936130 }
60946131
60956132 // / For a method of a class, checks whether it will require a new entry in the
@@ -6999,18 +7036,6 @@ class ConstructorDecl : public AbstractFunctionDecl {
69997036 // / \endcode
70007037 bool isObjCZeroParameterWithLongSelector () const ;
70017038
7002- // / Checks if the initializer is a distributed actor's 'local' initializer:
7003- // / ```
7004- // / init(transport: ActorTransport)
7005- // / ```
7006- bool isDistributedActorLocalInit () const ;
7007-
7008- // / Checks if the initializer is a distributed actor's 'resolve' initializer:
7009- // / ```
7010- // / init(resolve address: ActorAddress, using transport: ActorTransport)
7011- // / ```
7012- bool isDistributedActorResolveInit () const ;
7013-
70147039 static bool classof (const Decl *D) {
70157040 return D->getKind () == DeclKind::Constructor;
70167041 }
0 commit comments