File tree Expand file tree Collapse file tree 3 files changed +25
-20
lines changed Expand file tree Collapse file tree 3 files changed +25
-20
lines changed Original file line number Diff line number Diff line change @@ -3670,6 +3670,8 @@ class ClosureActorIsolation {
3670
3670
bool preconcurrency () const {
3671
3671
return storage.getInt ();
3672
3672
}
3673
+
3674
+ ActorIsolation getActorIsolation () const ;
3673
3675
};
3674
3676
3675
3677
// / A base class for closure expressions.
Original file line number Diff line number Diff line change @@ -9218,26 +9218,7 @@ ActorIsolation swift::getActorIsolationOfContext(DeclContext *dc) {
9218
9218
9219
9219
9220
9220
if (auto *closure = dyn_cast<AbstractClosureExpr>(dc)) {
9221
- switch (auto isolation = closure->getActorIsolation ()) {
9222
- case ClosureActorIsolation::Independent:
9223
- return ActorIsolation::forIndependent ()
9224
- .withPreconcurrency (isolation.preconcurrency ());
9225
-
9226
- case ClosureActorIsolation::GlobalActor: {
9227
- return ActorIsolation::forGlobalActor (
9228
- isolation.getGlobalActor (), /* unsafe=*/ false )
9229
- .withPreconcurrency (isolation.preconcurrency ());
9230
- }
9231
-
9232
- case ClosureActorIsolation::ActorInstance: {
9233
- auto selfDecl = isolation.getActorInstance ();
9234
- auto actor = selfDecl->getType ()->getReferenceStorageReferent ()
9235
- ->getAnyActor ();
9236
- assert (actor && " Bad closure actor isolation?" );
9237
- return ActorIsolation::forActorInstance (actor)
9238
- .withPreconcurrency (isolation.preconcurrency ());
9239
- }
9240
- }
9221
+ return closure->getActorIsolation ().getActorIsolation ();
9241
9222
}
9242
9223
9243
9224
if (auto *tld = dyn_cast<TopLevelCodeDecl>(dc)) {
Original file line number Diff line number Diff line change @@ -1732,6 +1732,28 @@ RebindSelfInConstructorExpr::getCalledConstructor(bool &isChainToSuper) const {
1732
1732
return otherCtorRef;
1733
1733
}
1734
1734
1735
+ ActorIsolation ClosureActorIsolation::getActorIsolation () const {
1736
+ switch (getKind ()) {
1737
+ case ClosureActorIsolation::Independent:
1738
+ return ActorIsolation::forIndependent ().withPreconcurrency (
1739
+ preconcurrency ());
1740
+
1741
+ case ClosureActorIsolation::GlobalActor: {
1742
+ return ActorIsolation::forGlobalActor (getGlobalActor (), /* unsafe=*/ false )
1743
+ .withPreconcurrency (preconcurrency ());
1744
+ }
1745
+
1746
+ case ClosureActorIsolation::ActorInstance: {
1747
+ auto selfDecl = getActorInstance ();
1748
+ auto actor =
1749
+ selfDecl->getType ()->getReferenceStorageReferent ()->getAnyActor ();
1750
+ assert (actor && " Bad closure actor isolation?" );
1751
+ return ActorIsolation::forActorInstance (actor).withPreconcurrency (
1752
+ preconcurrency ());
1753
+ }
1754
+ }
1755
+ }
1756
+
1735
1757
void AbstractClosureExpr::setParameterList (ParameterList *P) {
1736
1758
parameterList = P;
1737
1759
// Change the DeclContext of any parameters to be this closure.
You can’t perform that action at this time.
0 commit comments