@@ -69,6 +69,11 @@ class ActorIsolation {
69
69
// / The actor isolation iss statically erased, as for a call to
70
70
// / an isolated(any) function. This is not possible for declarations.
71
71
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,
72
77
};
73
78
74
79
private:
@@ -107,6 +112,12 @@ class ActorIsolation {
107
112
return ActorIsolation (unsafe ? NonisolatedUnsafe : Nonisolated);
108
113
}
109
114
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
+
110
121
static ActorIsolation forActorInstanceSelf (ValueDecl *decl);
111
122
112
123
// / Create an ActorIsolation appropriate for a type that is self.
@@ -152,8 +163,11 @@ class ActorIsolation {
152
163
ActorIsolation::NonisolatedUnsafe))
153
164
.Case (" global_actor" ,
154
165
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))
157
171
.Default (std::nullopt );
158
172
if (kind == std::nullopt )
159
173
return std::nullopt ;
@@ -180,8 +194,8 @@ class ActorIsolation {
180
194
return parameterIndex;
181
195
}
182
196
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.
185
199
bool isActorInstanceForSelfParameter () const {
186
200
return getActorInstanceParameter () == 0 ;
187
201
}
@@ -198,6 +212,7 @@ class ActorIsolation {
198
212
case Unspecified:
199
213
case Nonisolated:
200
214
case NonisolatedUnsafe:
215
+ case CallerIsolationInheriting:
201
216
return false ;
202
217
}
203
218
}
0 commit comments