@@ -267,7 +267,7 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
267
267
Kind : 2
268
268
);
269
269
270
- SWIFT_INLINE_BITFIELD (ClosureExpr, AbstractClosureExpr, 1 +1 +1 +1 +1 +1 +1 +1 ,
270
+ SWIFT_INLINE_BITFIELD (ClosureExpr, AbstractClosureExpr, 1 +1 +1 +1 +1 +1 +1 +1 + 1 ,
271
271
// / True if closure parameters were synthesized from anonymous closure
272
272
// / variables.
273
273
HasAnonymousClosureVars : 1 ,
@@ -276,9 +276,11 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
276
276
// / on each member reference.
277
277
ImplicitSelfCapture : 1 ,
278
278
279
- // / True if this @Sendable async closure parameter should implicitly
280
- // / inherit the actor context from where it was formed.
279
+ // / True if this closure parameter should implicitly inherit the actor
280
+ // / context from where it was formed.
281
281
InheritActorContext : 1 ,
282
+ // / The kind for inheritance - none or always at the moment.
283
+ InheritActorContextKind : 1 ,
282
284
283
285
// / True if this closure's actor isolation behavior was determined by an
284
286
// / \c \@preconcurrency declaration.
@@ -4318,6 +4320,7 @@ class ClosureExpr : public AbstractClosureExpr {
4318
4320
Bits.ClosureExpr .HasAnonymousClosureVars = false ;
4319
4321
Bits.ClosureExpr .ImplicitSelfCapture = false ;
4320
4322
Bits.ClosureExpr .InheritActorContext = false ;
4323
+ Bits.ClosureExpr .InheritActorContextKind = 0 ;
4321
4324
Bits.ClosureExpr .IsPassedToSendingParameter = false ;
4322
4325
Bits.ClosureExpr .NoGlobalActorAttribute = false ;
4323
4326
Bits.ClosureExpr .RequiresDynamicIsolationChecking = false ;
@@ -4366,8 +4369,29 @@ class ClosureExpr : public AbstractClosureExpr {
4366
4369
return Bits.ClosureExpr .InheritActorContext ;
4367
4370
}
4368
4371
4369
- void setInheritsActorContext (bool value = true ) {
4372
+ // / Whether this closure should _always_ implicitly inherit the actor context
4373
+ // / regardless of whether the isolation parameter is captured or not.
4374
+ bool alwaysInheritsActorContext () const {
4375
+ if (!inheritsActorContext ())
4376
+ return false ;
4377
+ return getInheritActorIsolationModifier () ==
4378
+ InheritActorContextModifier::Always;
4379
+ }
4380
+
4381
+ void setInheritsActorContext (bool value = true ,
4382
+ InheritActorContextModifier modifier =
4383
+ InheritActorContextModifier::None) {
4370
4384
Bits.ClosureExpr .InheritActorContext = value;
4385
+ Bits.ClosureExpr .InheritActorContextKind = uint8_t (modifier);
4386
+ assert ((static_cast <InheritActorContextModifier>(
4387
+ Bits.ClosureExpr .InheritActorContextKind ) == modifier) &&
4388
+ " not enough bits for modifier" );
4389
+ }
4390
+
4391
+ InheritActorContextModifier getInheritActorIsolationModifier () const {
4392
+ assert (inheritsActorContext ());
4393
+ return static_cast <InheritActorContextModifier>(
4394
+ Bits.ClosureExpr .InheritActorContextKind );
4371
4395
}
4372
4396
4373
4397
// / Whether the closure's concurrency behavior was determined by an
0 commit comments