@@ -550,6 +550,13 @@ class IsolationRestriction {
550
550
case DeclKind::Accessor:
551
551
case DeclKind::Func:
552
552
case DeclKind::Subscript:
553
+ // A function that provides an asynchronous context has no restrictions
554
+ // on its access.
555
+ if (auto func = dyn_cast<AbstractFunctionDecl>(decl)) {
556
+ if (func->isAsyncContext ())
557
+ return forUnrestricted ();
558
+ }
559
+
553
560
// Local captures can only be referenced in their local context or a
554
561
// context that is guaranteed not to run concurrently with it.
555
562
if (cast<ValueDecl>(decl)->isLocalCapture ())
@@ -565,10 +572,7 @@ class IsolationRestriction {
565
572
return forGlobalActor (isolation.getGlobalActor ());
566
573
567
574
case ActorIsolation::Independent:
568
- case ActorIsolation::ActorPrivileged:
569
- case ActorIsolation::GlobalActorPrivileged:
570
- // Actor-independent and actor-privileged declarations have no
571
- // restrictions on their access.
575
+ // Actor-independent have no restrictions on their access.
572
576
return forUnrestricted ();
573
577
574
578
case ActorIsolation::Unspecified:
@@ -869,7 +873,6 @@ void swift::checkActorIsolation(const Expr *expr, const DeclContext *dc) {
869
873
switch (auto contextIsolation =
870
874
getInnermostIsolatedContext (getDeclContext ())) {
871
875
case ActorIsolation::ActorInstance:
872
- case ActorIsolation::ActorPrivileged:
873
876
ctx.Diags .diagnose (
874
877
loc, diag::global_actor_from_instance_actor_context,
875
878
value->getDescriptiveKind (), value->getName (), globalActor,
@@ -878,7 +881,6 @@ void swift::checkActorIsolation(const Expr *expr, const DeclContext *dc) {
878
881
return true ;
879
882
880
883
case ActorIsolation::GlobalActor:
881
- case ActorIsolation::GlobalActorPrivileged:
882
884
// If the global actor types are the same, we're done.
883
885
if (contextIsolation.getGlobalActor ()->isEqual (globalActor))
884
886
return false ;
@@ -973,7 +975,6 @@ void swift::checkActorIsolation(const Expr *expr, const DeclContext *dc) {
973
975
switch (auto contextIsolation = getActorIsolation (
974
976
cast<ValueDecl>(selfVar->getDeclContext ()->getAsDecl ()))) {
975
977
case ActorIsolation::ActorInstance:
976
- case ActorIsolation::ActorPrivileged:
977
978
// An escaping partial application of something that is part of
978
979
// the actor's isolated state is never permitted.
979
980
if (isEscapingPartialApply) {
@@ -1001,7 +1002,6 @@ void swift::checkActorIsolation(const Expr *expr, const DeclContext *dc) {
1001
1002
return true ;
1002
1003
1003
1004
case ActorIsolation::GlobalActor:
1004
- case ActorIsolation::GlobalActorPrivileged:
1005
1005
// The 'self' is for a member that's part of a global actor, which
1006
1006
// means we cannot refer to actor-isolated state.
1007
1007
ctx.Diags .diagnose (
@@ -1081,12 +1081,6 @@ ActorIsolation ActorIsolationRequest::evaluate(
1081
1081
if (!globalActorType || globalActorType->hasError ())
1082
1082
return ActorIsolation::forUnspecified ();
1083
1083
1084
- // A function that is an asynchronous context is actor-privileged.
1085
- if (auto func = dyn_cast<AbstractFunctionDecl>(value)) {
1086
- if (func->isAsyncContext ())
1087
- return ActorIsolation::forGlobalActorPrivileged (globalActorType);
1088
- }
1089
-
1090
1084
return ActorIsolation::forGlobalActor (globalActorType);
1091
1085
}
1092
1086
@@ -1104,13 +1098,7 @@ ActorIsolation ActorIsolationRequest::evaluate(
1104
1098
// actor-isolated state.
1105
1099
auto classDecl = value->getDeclContext ()->getSelfClassDecl ();
1106
1100
if (classDecl && classDecl->isActor () && value->isInstanceMember ()) {
1107
- // A function that is an asynchronous context is actor-privileged.
1108
- if (auto func = dyn_cast<AbstractFunctionDecl>(value)) {
1109
- if (func->isAsyncContext ())
1110
- return ActorIsolation::forActorPrivileged (classDecl);
1111
- }
1112
-
1113
- // Everything else is part of the actor's isolated state.
1101
+ // Part of the actor's isolated state.
1114
1102
return ActorIsolation::forActorInstance (classDecl);
1115
1103
}
1116
1104
0 commit comments