File tree Expand file tree Collapse file tree 3 files changed +26
-21
lines changed Expand file tree Collapse file tree 3 files changed +26
-21
lines changed Original file line number Diff line number Diff line change @@ -3658,6 +3658,8 @@ class ClosureActorIsolation {
3658
3658
bool preconcurrency () const {
3659
3659
return storage.getInt ();
3660
3660
}
3661
+
3662
+ ActorIsolation getActorIsolation () const ;
3661
3663
};
3662
3664
3663
3665
// / A base class for closure expressions.
Original file line number Diff line number Diff line change @@ -9220,27 +9220,7 @@ ActorIsolation swift::getActorIsolationOfContext(DeclContext *dc) {
9220
9220
9221
9221
9222
9222
if (auto *closure = dyn_cast<AbstractClosureExpr>(dc)) {
9223
- switch (auto isolation = closure->getActorIsolation ()) {
9224
- case ClosureActorIsolation::Independent:
9225
- return ActorIsolation::forIndependent ()
9226
- .withPreconcurrency (isolation.preconcurrency ());
9227
-
9228
- case ClosureActorIsolation::GlobalActor: {
9229
- return ActorIsolation::forGlobalActor (
9230
- isolation.getGlobalActor (), /* unsafe=*/ false )
9231
- .withPreconcurrency (isolation.preconcurrency ());
9232
- }
9233
-
9234
- case ClosureActorIsolation::ActorInstance: {
9235
- auto selfDecl = isolation.getActorInstance ();
9236
- auto actor = selfDecl->getType ()->getReferenceStorageReferent ()
9237
- ->getAnyActor ();
9238
- assert (actor && " Bad closure actor isolation?" );
9239
- // FIXME: This could be a parameter... or a capture... hmmm.
9240
- return ActorIsolation::forActorInstanceSelf (actor)
9241
- .withPreconcurrency (isolation.preconcurrency ());
9242
- }
9243
- }
9223
+ return closure->getActorIsolation ().getActorIsolation ();
9244
9224
}
9245
9225
9246
9226
if (auto *tld = dyn_cast<TopLevelCodeDecl>(dc)) {
Original file line number Diff line number Diff line change @@ -1779,6 +1779,29 @@ RebindSelfInConstructorExpr::getCalledConstructor(bool &isChainToSuper) const {
1779
1779
return otherCtorRef;
1780
1780
}
1781
1781
1782
+ ActorIsolation ClosureActorIsolation::getActorIsolation () const {
1783
+ switch (getKind ()) {
1784
+ case ClosureActorIsolation::Independent:
1785
+ return ActorIsolation::forIndependent ().withPreconcurrency (
1786
+ preconcurrency ());
1787
+
1788
+ case ClosureActorIsolation::GlobalActor: {
1789
+ return ActorIsolation::forGlobalActor (getGlobalActor (), /* unsafe=*/ false )
1790
+ .withPreconcurrency (preconcurrency ());
1791
+ }
1792
+
1793
+ case ClosureActorIsolation::ActorInstance: {
1794
+ auto selfDecl = getActorInstance ();
1795
+ auto actor =
1796
+ selfDecl->getType ()->getReferenceStorageReferent ()->getAnyActor ();
1797
+ assert (actor && " Bad closure actor isolation?" );
1798
+ // FIXME: This could be a parameter... or a capture... hmmm.
1799
+ return ActorIsolation::forActorInstanceSelf (actor).withPreconcurrency (
1800
+ preconcurrency ());
1801
+ }
1802
+ }
1803
+ }
1804
+
1782
1805
void AbstractClosureExpr::setParameterList (ParameterList *P) {
1783
1806
parameterList = P;
1784
1807
// Change the DeclContext of any parameters to be this closure.
You can’t perform that action at this time.
0 commit comments