@@ -4836,9 +4836,8 @@ bool swift::isThrowsDecl(ConcreteDeclRef declRef) {
48364836 return false ;
48374837}
48384838
4839- bool swift::isAccessibleAcrossActors (
4840- ValueDecl *value, const ActorIsolation &isolation,
4841- const DeclContext *fromDC, Optional<ReferencedActor> actorInstance) {
4839+ // / Determine whether a reference to this value isn't actually a value.
4840+ static bool isNonValueReference (const ValueDecl *value) {
48424841 switch (value->getKind ()) {
48434842 case DeclKind::AssociatedType:
48444843 case DeclKind::Class:
@@ -4849,13 +4848,7 @@ bool swift::isAccessibleAcrossActors(
48494848 case DeclKind::Protocol:
48504849 case DeclKind::Struct:
48514850 case DeclKind::TypeAlias:
4852- return true ;
4853-
48544851 case DeclKind::EnumCase:
4855- case DeclKind::EnumElement:
4856- // Type-level entities are always accessible across actors.
4857- return true ;
4858-
48594852 case DeclKind::IfConfig:
48604853 case DeclKind::Import:
48614854 case DeclKind::InfixOperator:
@@ -4867,16 +4860,26 @@ bool swift::isAccessibleAcrossActors(
48674860 case DeclKind::PrecedenceGroup:
48684861 case DeclKind::PrefixOperator:
48694862 case DeclKind::TopLevelCode:
4870- // Non-value entities are always accessible across actors.
4871- return true ;
4872-
48734863 case DeclKind::Destructor:
4874- // Destructors are always accessible across actors.
48754864 return true ;
48764865
4866+ case DeclKind::EnumElement:
48774867 case DeclKind::Constructor:
4878- // Initializers are accessible across actors unless they are global-actor
4879- // qualified.
4868+ case DeclKind::Param:
4869+ case DeclKind::Var:
4870+ case DeclKind::Accessor:
4871+ case DeclKind::Func:
4872+ case DeclKind::Subscript:
4873+ return false ;
4874+ }
4875+ }
4876+
4877+ bool swift::isAccessibleAcrossActors (
4878+ ValueDecl *value, const ActorIsolation &isolation,
4879+ const DeclContext *fromDC, Optional<ReferencedActor> actorInstance) {
4880+ // Initializers and enum elements are accessible across actors unless they
4881+ // are global-actor qualified.
4882+ if (isa<ConstructorDecl>(value) || isa<EnumElementDecl>(value)) {
48804883 switch (isolation) {
48814884 case ActorIsolation::ActorInstance:
48824885 case ActorIsolation::Independent:
@@ -4887,19 +4890,15 @@ bool swift::isAccessibleAcrossActors(
48874890 case ActorIsolation::GlobalActor:
48884891 return false ;
48894892 }
4893+ }
48904894
4891- case DeclKind::Param:
4892- case DeclKind::Var:
4893- // 'let' declarations are immutable, so some of them can be accessed across
4894- // actors.
4895- return varIsSafeAcrossActors (
4896- fromDC->getParentModule (), cast<VarDecl>(value), isolation);
4897-
4898- case DeclKind::Accessor:
4899- case DeclKind::Func:
4900- case DeclKind::Subscript:
4901- return false ;
4895+ // 'let' declarations are immutable, so some of them can be accessed across
4896+ // actors.
4897+ if (auto var = dyn_cast<VarDecl>(value)) {
4898+ return varIsSafeAcrossActors (fromDC->getParentModule (), var, isolation);
49024899 }
4900+
4901+ return false ;
49034902}
49044903
49054904ActorReferenceResult ActorReferenceResult::forSameConcurrencyDomain (
@@ -4948,6 +4947,11 @@ ActorReferenceResult ActorReferenceResult::forReference(
49484947 declIsolation = declIsolation.subst (declRef.getSubstitutions ());
49494948 }
49504949
4950+ // If the entity we are referencing is not a value, we're in thesame
4951+ // concurrency domain.
4952+ if (isNonValueReference (declRef.getDecl ()))
4953+ return forSameConcurrencyDomain (declIsolation);
4954+
49514955 // Compute the isolation of the context, if not provided.
49524956 ActorIsolation contextIsolation = ActorIsolation::forUnspecified ();
49534957 if (knownContextIsolation) {
0 commit comments