@@ -57,19 +57,8 @@ class ActorIsolation {
5757 // / the actor is isolated to the instance of that actor.
5858 ActorInstance,
5959 // / The declaration is explicitly specified to be not isolated to any actor,
60- // / meaning it cannot itself access actor isolated state but /does/ allow
61- // / for indirect access to actor isolated state if the declaration can
62- // / guarantee that all code generated to work with the declaration will run
63- // / on said actor.
64- // /
65- // / E.x.: a nonisolated function can accept actor-isolated values as
66- // / arguments since the caller knows that it will not escape the values to
67- // / another isolation domain and that the function will remain on the
68- // / caller's actor.
69- // /
70- // / NOTE: This used to have the meaning of Concurrent which is a stricter
71- // / definition of nonisolated that prevents the code generated to work with
72- // / the declaration to never touch actor isolated state.
60+ // / meaning that it can be used from any actor but is also unable to
61+ // / refer to the isolated state of any given actor.
7362 Nonisolated,
7463 // / The declaration is explicitly specified to be not isolated and with the
7564 // / "unsafe" annotation, which means that we do not enforce isolation.
@@ -80,20 +69,11 @@ class ActorIsolation {
8069 // / The actor isolation iss statically erased, as for a call to
8170 // / an isolated(any) function. This is not possible for declarations.
8271 Erased,
83- // / The declaration is explicitly specified to be not isolated to any actor,
84- // / meaning that it can be used from any actor but is also unable to
85- // / refer to the isolated state of any given actor.
72+ // / Inherits isolation from the caller of the given function.
8673 // /
87- // / NOTE: This used to be nonisolated, but we changed nonisolated to have a
88- // / weaker definition of nonisolated that allows for actor isolated state to
89- // / be manipulated by code generated to work with the actor as long as all
90- // / such code generation is guaranteed to always run on whatever actor
91- // / isolation it is invoked in consistently and not escape the value to any
92- // / other isolation domain.
93- Concurrent,
94- // / The declaration is explicitly specified to be concurrent and with the
95- // / "unsafe" annotation, which means that we do not enforce isolation.
96- ConcurrentUnsafe,
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,
9777 };
9878
9979private:
@@ -108,7 +88,7 @@ class ActorIsolation {
10888 // / Set to true if this was parsed from SIL.
10989 unsigned silParsed : 1 ;
11090
111- unsigned parameterIndex : 26 ;
91+ unsigned parameterIndex : 27 ;
11292
11393 ActorIsolation (Kind kind, NominalTypeDecl *actor, unsigned parameterIndex);
11494
@@ -132,8 +112,10 @@ class ActorIsolation {
132112 return ActorIsolation (unsafe ? NonisolatedUnsafe : Nonisolated);
133113 }
134114
135- static ActorIsolation forConcurrent (bool unsafe) {
136- return ActorIsolation (unsafe ? ConcurrentUnsafe : Concurrent);
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);
137119 }
138120
139121 static ActorIsolation forActorInstanceSelf (ValueDecl *decl);
@@ -183,10 +165,9 @@ class ActorIsolation {
183165 std::optional<ActorIsolation>(ActorIsolation::GlobalActor))
184166 .Case (" global_actor_unsafe" ,
185167 std::optional<ActorIsolation>(ActorIsolation::GlobalActor))
186- .Case (" concurrent" ,
187- std::optional<ActorIsolation>(ActorIsolation::Concurrent))
188- .Case (" concurrent_unsafe" , std::optional<ActorIsolation>(
189- ActorIsolation::ConcurrentUnsafe))
168+ .Case (" caller_isolation_inheriting" ,
169+ std::optional<ActorIsolation>(
170+ ActorIsolation::CallerIsolationInheriting))
190171 .Default (std::nullopt );
191172 if (kind == std::nullopt )
192173 return std::nullopt ;
@@ -199,17 +180,11 @@ class ActorIsolation {
199180
200181 bool isUnspecified () const { return kind == Unspecified; }
201182
202- bool isConcurrent () const {
203- return (kind == Concurrent) || (kind == ConcurrentUnsafe);
204- }
205-
206183 bool isNonisolated () const {
207184 return (kind == Nonisolated) || (kind == NonisolatedUnsafe);
208185 }
209186
210- bool isUnsafe () const {
211- return kind == NonisolatedUnsafe || kind == ConcurrentUnsafe;
212- }
187+ bool isNonisolatedUnsafe () const { return kind == NonisolatedUnsafe; }
213188
214189 // / Retrieve the parameter to which actor-instance isolation applies.
215190 // /
@@ -237,8 +212,7 @@ class ActorIsolation {
237212 case Unspecified:
238213 case Nonisolated:
239214 case NonisolatedUnsafe:
240- case Concurrent:
241- case ConcurrentUnsafe:
215+ case CallerIsolationInheriting:
242216 return false ;
243217 }
244218 }
0 commit comments