@@ -69,6 +69,11 @@ class ActorIsolation {
6969 // / The actor isolation iss statically erased, as for a call to
7070 // / an isolated(any) function. This is not possible for declarations.
7171 Erased,
72+ // / Inherits isolation from the caller of the given function.
73+ // /
74+ // / DISCUSSION: This is used for nonisolated asynchronous functions that we
75+ // / want to inherit from their context the context's actor isolation.
76+ CallerIsolationInheriting,
7277 };
7378
7479private:
@@ -107,6 +112,12 @@ class ActorIsolation {
107112 return ActorIsolation (unsafe ? NonisolatedUnsafe : Nonisolated);
108113 }
109114
115+ static ActorIsolation forCallerIsolationInheriting () {
116+ // NOTE: We do not use parameter indices since the parameter is implicit
117+ // from the perspective of the AST.
118+ return ActorIsolation (CallerIsolationInheriting);
119+ }
120+
110121 static ActorIsolation forActorInstanceSelf (ValueDecl *decl);
111122
112123 // / Create an ActorIsolation appropriate for a type that is self.
@@ -152,8 +163,11 @@ class ActorIsolation {
152163 ActorIsolation::NonisolatedUnsafe))
153164 .Case (" global_actor" ,
154165 std::optional<ActorIsolation>(ActorIsolation::GlobalActor))
155- .Case (" global_actor_unsafe" , std::optional<ActorIsolation>(
156- ActorIsolation::GlobalActor))
166+ .Case (" global_actor_unsafe" ,
167+ std::optional<ActorIsolation>(ActorIsolation::GlobalActor))
168+ .Case (" caller_isolation_inheriting" ,
169+ std::optional<ActorIsolation>(
170+ ActorIsolation::CallerIsolationInheriting))
157171 .Default (std::nullopt );
158172 if (kind == std::nullopt )
159173 return std::nullopt ;
@@ -180,8 +194,8 @@ class ActorIsolation {
180194 return parameterIndex;
181195 }
182196
183- // / Returns true if this actor-instance isolation applies to the self
184- // / parameter of a method.
197+ // / Returns true if this is an actor-instance isolation that additionally
198+ // / applies to the self parameter of a method.
185199 bool isActorInstanceForSelfParameter () const {
186200 return getActorInstanceParameter () == 0 ;
187201 }
@@ -198,6 +212,7 @@ class ActorIsolation {
198212 case Unspecified:
199213 case Nonisolated:
200214 case NonisolatedUnsafe:
215+ case CallerIsolationInheriting:
201216 return false ;
202217 }
203218 }
0 commit comments