Skip to content

Commit a1daee5

Browse files
committed
a distributed actor's convenience init should be treated as nonisolated
1 parent 573ae9b commit a1daee5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3230,9 +3230,9 @@ ActorIsolation ActorIsolationRequest::evaluate(
32303230
}
32313231
}
32323232

3233-
// An actor's convenience init is assumed to be actor-independent.
3233+
// Every actor's convenience init is assumed to be actor-independent.
32343234
if (auto nominal = value->getDeclContext()->getSelfNominalTypeDecl())
3235-
if (nominal->isActor())
3235+
if (nominal->isAnyActor())
32363236
if (auto ctor = dyn_cast<ConstructorDecl>(value))
32373237
if (ctor->isConvenienceInit())
32383238
defaultIsolation = ActorIsolation::forIndependent();

test/Distributed/distributed_actor_isolation.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,13 @@ func test_params(
172172
_ = try await distributed.distInt(int: 42) // ok
173173
_ = try await distributed.dist(notCodable: .init())
174174
}
175+
176+
// Actor initializer isolation (through typechecking only!)
177+
distributed actor DijonMustard {
178+
convenience init(conv: ActorTransport) {
179+
self.init(transport: conv)
180+
self.f() // expected-error {{actor-isolated instance method 'f()' can not be referenced from a non-isolated context}}
181+
}
182+
183+
func f() {} // expected-note {{distributed actor-isolated instance method 'f()' declared here}}
184+
}

0 commit comments

Comments
 (0)