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 @@ -9215,26 +9215,7 @@ ActorIsolation swift::getActorIsolationOfContext(DeclContext *dc) {
9215
9215
9216
9216
9217
9217
if (auto *closure = dyn_cast<AbstractClosureExpr>(dc)) {
9218
- switch (auto isolation = closure->getActorIsolation ()) {
9219
- case ClosureActorIsolation::Independent:
9220
- return ActorIsolation::forIndependent ()
9221
- .withPreconcurrency (isolation.preconcurrency ());
9222
-
9223
- case ClosureActorIsolation::GlobalActor: {
9224
- return ActorIsolation::forGlobalActor (
9225
- isolation.getGlobalActor (), /* unsafe=*/ false )
9226
- .withPreconcurrency (isolation.preconcurrency ());
9227
- }
9228
-
9229
- case ClosureActorIsolation::ActorInstance: {
9230
- auto selfDecl = isolation.getActorInstance ();
9231
- auto actor = selfDecl->getType ()->getReferenceStorageReferent ()
9232
- ->getAnyActor ();
9233
- assert (actor && " Bad closure actor isolation?" );
9234
- return ActorIsolation::forActorInstance (actor)
9235
- .withPreconcurrency (isolation.preconcurrency ());
9236
- }
9237
- }
9218
+ return closure->getActorIsolation ().getActorIsolation ();
9238
9219
}
9239
9220
9240
9221
if (auto *tld = dyn_cast<TopLevelCodeDecl>(dc)) {
Original file line number Diff line number Diff line change @@ -1737,6 +1737,28 @@ RebindSelfInConstructorExpr::getCalledConstructor(bool &isChainToSuper) const {
1737
1737
return otherCtorRef;
1738
1738
}
1739
1739
1740
+ ActorIsolation ClosureActorIsolation::getActorIsolation () const {
1741
+ switch (getKind ()) {
1742
+ case ClosureActorIsolation::Independent:
1743
+ return ActorIsolation::forIndependent ().withPreconcurrency (
1744
+ preconcurrency ());
1745
+
1746
+ case ClosureActorIsolation::GlobalActor: {
1747
+ return ActorIsolation::forGlobalActor (getGlobalActor (), /* unsafe=*/ false )
1748
+ .withPreconcurrency (preconcurrency ());
1749
+ }
1750
+
1751
+ case ClosureActorIsolation::ActorInstance: {
1752
+ auto selfDecl = getActorInstance ();
1753
+ auto actor =
1754
+ selfDecl->getType ()->getReferenceStorageReferent ()->getAnyActor ();
1755
+ assert (actor && " Bad closure actor isolation?" );
1756
+ return ActorIsolation::forActorInstance (actor).withPreconcurrency (
1757
+ preconcurrency ());
1758
+ }
1759
+ }
1760
+ }
1761
+
1740
1762
void AbstractClosureExpr::setParameterList (ParameterList *P) {
1741
1763
parameterList = P;
1742
1764
// Change the DeclContext of any parameters to be this closure.
You can’t perform that action at this time.
0 commit comments