@@ -57,19 +57,8 @@ class ActorIsolation {
57
57
// / the actor is isolated to the instance of that actor.
58
58
ActorInstance,
59
59
// / 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.
73
62
Nonisolated,
74
63
// / The declaration is explicitly specified to be not isolated and with the
75
64
// / "unsafe" annotation, which means that we do not enforce isolation.
@@ -80,20 +69,11 @@ class ActorIsolation {
80
69
// / The actor isolation iss statically erased, as for a call to
81
70
// / an isolated(any) function. This is not possible for declarations.
82
71
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.
86
73
// /
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,
97
77
};
98
78
99
79
private:
@@ -108,7 +88,7 @@ class ActorIsolation {
108
88
// / Set to true if this was parsed from SIL.
109
89
unsigned silParsed : 1 ;
110
90
111
- unsigned parameterIndex : 26 ;
91
+ unsigned parameterIndex : 27 ;
112
92
113
93
ActorIsolation (Kind kind, NominalTypeDecl *actor, unsigned parameterIndex);
114
94
@@ -132,8 +112,10 @@ class ActorIsolation {
132
112
return ActorIsolation (unsafe ? NonisolatedUnsafe : Nonisolated);
133
113
}
134
114
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);
137
119
}
138
120
139
121
static ActorIsolation forActorInstanceSelf (ValueDecl *decl);
@@ -183,10 +165,9 @@ class ActorIsolation {
183
165
std::optional<ActorIsolation>(ActorIsolation::GlobalActor))
184
166
.Case (" global_actor_unsafe" ,
185
167
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))
190
171
.Default (std::nullopt );
191
172
if (kind == std::nullopt )
192
173
return std::nullopt ;
@@ -199,17 +180,11 @@ class ActorIsolation {
199
180
200
181
bool isUnspecified () const { return kind == Unspecified; }
201
182
202
- bool isConcurrent () const {
203
- return (kind == Concurrent) || (kind == ConcurrentUnsafe);
204
- }
205
-
206
183
bool isNonisolated () const {
207
184
return (kind == Nonisolated) || (kind == NonisolatedUnsafe);
208
185
}
209
186
210
- bool isUnsafe () const {
211
- return kind == NonisolatedUnsafe || kind == ConcurrentUnsafe;
212
- }
187
+ bool isNonisolatedUnsafe () const { return kind == NonisolatedUnsafe; }
213
188
214
189
// / Retrieve the parameter to which actor-instance isolation applies.
215
190
// /
@@ -237,8 +212,7 @@ class ActorIsolation {
237
212
case Unspecified:
238
213
case Nonisolated:
239
214
case NonisolatedUnsafe:
240
- case Concurrent:
241
- case ConcurrentUnsafe:
215
+ case CallerIsolationInheriting:
242
216
return false ;
243
217
}
244
218
}
0 commit comments