Skip to content

Commit 070d13c

Browse files
committed
Loosen key path restrictions for global actor-isolated properties.
We need to tie this in more deeply with Sendable for it to make sense. Fixes rdar://75839460.
1 parent 6207dd8 commit 070d13c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,12 @@ namespace {
19441944
LLVM_FALLTHROUGH; // otherwise, perform checking
19451945

19461946
case ActorIsolationRestriction::GlobalActor:
1947+
// Disable global actor checking for now.
1948+
if (!ctx.LangOpts.isSwiftVersionAtLeast(6))
1949+
break;
1950+
1951+
LLVM_FALLTHROUGH; // otherwise, it's invalid so diagnose it.
1952+
19471953
case ActorIsolationRestriction::CrossActorSelf:
19481954
// 'let'-bound decls with this isolation are OK, just check them.
19491955
if (auto wasLetBound = checkLetBoundVarDecl(component)) {

test/Concurrency/actor_keypath_isolation.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func tryKeyPathsMisc(d : Door) {
5757

5858
func tryKeyPathsFromAsync() async {
5959
_ = \Door.unsafeGlobActor_immutable
60-
_ = \Door.unsafeGlobActor_mutable // expected-error{{cannot form key path to actor-isolated property 'unsafeGlobActor_mutable'}}
60+
_ = \Door.unsafeGlobActor_mutable // okay for now
6161
}
6262

6363
func tryNonSendable() {
@@ -68,7 +68,7 @@ func tryNonSendable() {
6868

6969
func tryKeypaths() {
7070
_ = \Door.unsafeGlobActor_immutable
71-
_ = \Door.unsafeGlobActor_mutable // expected-error{{cannot form key path to actor-isolated property 'unsafeGlobActor_mutable'}}
71+
_ = \Door.unsafeGlobActor_mutable // okay for now
7272

7373
_ = \Door.immutable
7474
_ = \Door.unsafeIndependent
@@ -84,7 +84,7 @@ func tryKeypaths() {
8484
let _ : PartialKeyPath<Door> = \.mutable // expected-error{{cannot form key path to actor-isolated property 'mutable'}}
8585
let _ : AnyKeyPath = \Door.mutable // expected-error{{cannot form key path to actor-isolated property 'mutable'}}
8686

87-
_ = \Door.globActor_mutable // expected-error{{cannot form key path to actor-isolated property 'globActor_mutable'}}
87+
_ = \Door.globActor_mutable // okay for now
8888
_ = \Door.[0] // expected-error{{cannot form key path to actor-isolated subscript 'subscript(_:)'}}
89-
_ = \Door.["hello"] // expected-error{{cannot form key path to actor-isolated subscript 'subscript(_:)'}}
89+
_ = \Door.["hello"] // okay for now
9090
}

0 commit comments

Comments
 (0)