@@ -292,10 +292,18 @@ class alignas(8) Expr {
292
292
Kind : 2
293
293
);
294
294
295
- SWIFT_INLINE_BITFIELD (ClosureExpr, AbstractClosureExpr, 1 ,
295
+ SWIFT_INLINE_BITFIELD (ClosureExpr, AbstractClosureExpr, 1 + 1 + 1 ,
296
296
// / True if closure parameters were synthesized from anonymous closure
297
297
// / variables.
298
- HasAnonymousClosureVars : 1
298
+ HasAnonymousClosureVars : 1 ,
299
+
300
+ // / True if "self" can be captured implicitly without requiring "self."
301
+ // / on each member reference.
302
+ ImplicitSelfCapture : 1 ,
303
+
304
+ // / True if this @Sendable async closure parameter should implicitly
305
+ // / inherit the actor context from where it was formed.
306
+ InheritActorContext : 1
299
307
);
300
308
301
309
SWIFT_INLINE_BITFIELD_FULL (BindOptionalExpr, Expr, 16 ,
@@ -3871,6 +3879,8 @@ class ClosureExpr : public AbstractClosureExpr {
3871
3879
Body(nullptr ) {
3872
3880
setParameterList (params);
3873
3881
Bits.ClosureExpr .HasAnonymousClosureVars = false ;
3882
+ Bits.ClosureExpr .ImplicitSelfCapture = false ;
3883
+ Bits.ClosureExpr .InheritActorContext = false ;
3874
3884
}
3875
3885
3876
3886
SourceRange getSourceRange () const ;
@@ -3898,7 +3908,27 @@ class ClosureExpr : public AbstractClosureExpr {
3898
3908
void setHasAnonymousClosureVars () {
3899
3909
Bits.ClosureExpr .HasAnonymousClosureVars = true ;
3900
3910
}
3901
-
3911
+
3912
+ // / Whether this closure allows "self" to be implicitly captured without
3913
+ // / required "self." on each reference.
3914
+ bool allowsImplicitSelfCapture () const {
3915
+ return Bits.ClosureExpr .ImplicitSelfCapture ;
3916
+ }
3917
+
3918
+ void setAllowsImplicitSelfCapture (bool value = true ) {
3919
+ Bits.ClosureExpr .ImplicitSelfCapture = value;
3920
+ }
3921
+
3922
+ // / Whether this closure should implicitly inherit the actor context from
3923
+ // / where it was formed. This only affects @Sendable async closures.
3924
+ bool inheritsActorContext () const {
3925
+ return Bits.ClosureExpr .InheritActorContext ;
3926
+ }
3927
+
3928
+ void setInheritsActorContext (bool value = true ) {
3929
+ Bits.ClosureExpr .InheritActorContext = value;
3930
+ }
3931
+
3902
3932
// / Determine whether this closure expression has an
3903
3933
// / explicitly-specified result type.
3904
3934
bool hasExplicitResultType () const { return ArrowLoc.isValid (); }
0 commit comments