Skip to content

Commit e0767e0

Browse files
committed
Stop relying on @_distributedActorIndependent anywhere.
This is an non-user-visible attribute that is semantically identical to `nonisolated` except that it allows use in distributed actors. It is only, and can only, be used for the two fields that distributed actors have in both the local actor and in the remote proxy, "id" and "actorTransport". So, special-case the "nonisolated" check for those fields and stop using `@_distributedActorIndependent`.
1 parent f7cd8e9 commit e0767e0

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

lib/SILGen/SILGenDistributed.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ void SILGenFunction::emitDistributedActorClassMemberDestruction(
817817
B.emitBlock(remoteMemberDestroyBB);
818818

819819
for (VarDecl *vd : cd->getStoredProperties()) {
820-
if (!vd->getAttrs().hasAttribute<DistributedActorIndependentAttr>())
820+
if (getActorIsolation(vd) == ActorIsolation::DistributedActorInstance)
821821
continue;
822822

823823
destroyClassMember(cleanupLoc, selfValue, vd);

lib/Sema/CodeSynthesisDistributedActor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,8 @@ AbstractFunctionDecl *TypeChecker::addImplicitDistributedActorRemoteFunction(
172172
remoteFuncDecl->getAttrs().add(
173173
new (C) DynamicAttr(/*implicit=*/true));
174174

175-
// @_distributedActorIndependent
176-
remoteFuncDecl->getAttrs().add(
177-
new (C) DistributedActorIndependentAttr(/*IsImplicit=*/true));
175+
// nonisolated
176+
remoteFuncDecl->getAttrs().add(new (C) NonisolatedAttr(/*IsImplicit=*/true));
178177

179178
// users should never have to access this function directly;
180179
// it is only invoked from our distributed function thunk if the actor is remote.

lib/Sema/DerivedConformanceDistributedActor.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ static ValueDecl *deriveDistributedActor_id(DerivedConformance &derived) {
119119

120120
propDecl->setIntroducer(VarDecl::Introducer::Let);
121121

122-
// mark as @_distributedActorIndependent, allowing access to it from everywhere
122+
// mark as nonisolated, allowing access to it from everywhere
123123
propDecl->getAttrs().add(
124-
new (C) DistributedActorIndependentAttr(/*IsImplicit=*/true));
124+
new (C) NonisolatedAttr(/*IsImplicit=*/true));
125125

126126
derived.addMembersToConformanceContext({ propDecl, pbDecl });
127127
return propDecl;
@@ -148,9 +148,9 @@ static ValueDecl *deriveDistributedActor_actorTransport(
148148

149149
propDecl->setIntroducer(VarDecl::Introducer::Let);
150150

151-
// mark as @_distributedActorIndependent, allowing access to it from everywhere
151+
// mark as nonisolated, allowing access to it from everywhere
152152
propDecl->getAttrs().add(
153-
new (C) DistributedActorIndependentAttr(/*IsImplicit=*/true));
153+
new (C) NonisolatedAttr(/*IsImplicit=*/true));
154154

155155
derived.addMembersToConformanceContext({ propDecl, pbDecl });
156156
return propDecl;

lib/Sema/TypeCheckAttr.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5473,7 +5473,13 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
54735473
// distributed actors. Attempts of nonisolated access would be
54745474
// cross-actor, and that means they might be accessing on a remote actor,
54755475
// in which case the stored property storage does not exist.
5476-
if (nominal && nominal->isDistributedActor()) {
5476+
//
5477+
// The synthesized "id" and "actorTransport" are the only exceptions,
5478+
// because the implementation mirrors them.
5479+
if (nominal && nominal->isDistributedActor() &&
5480+
!(var->isImplicit() &&
5481+
(var->getName() == Ctx.Id_id ||
5482+
var->getName() == Ctx.Id_actorTransport))) {
54775483
diagnoseAndRemoveAttr(attr,
54785484
diag::nonisolated_distributed_actor_storage);
54795485
return;

0 commit comments

Comments
 (0)