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 @@ -9226,27 +9226,7 @@ ActorIsolation swift::getActorIsolationOfContext(DeclContext *dc) {
9226
9226
return getActorIsolation (var);
9227
9227
9228
9228
if (auto *closure = dyn_cast<AbstractClosureExpr>(dcToUse)) {
9229
- switch (auto isolation = closure->getActorIsolation ()) {
9230
- case ClosureActorIsolation::Independent:
9231
- return ActorIsolation::forIndependent ()
9232
- .withPreconcurrency (isolation.preconcurrency ());
9233
-
9234
- case ClosureActorIsolation::GlobalActor: {
9235
- return ActorIsolation::forGlobalActor (
9236
- isolation.getGlobalActor (), /* unsafe=*/ false )
9237
- .withPreconcurrency (isolation.preconcurrency ());
9238
- }
9239
-
9240
- case ClosureActorIsolation::ActorInstance: {
9241
- auto selfDecl = isolation.getActorInstance ();
9242
- auto actor = selfDecl->getType ()->getReferenceStorageReferent ()
9243
- ->getAnyActor ();
9244
- assert (actor && " Bad closure actor isolation?" );
9245
- // FIXME: This could be a parameter... or a capture... hmmm.
9246
- return ActorIsolation::forActorInstanceSelf (actor)
9247
- .withPreconcurrency (isolation.preconcurrency ());
9248
- }
9249
- }
9229
+ return closure->getActorIsolation ().getActorIsolation ();
9250
9230
}
9251
9231
9252
9232
if (auto *tld = dyn_cast<TopLevelCodeDecl>(dcToUse)) {
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