Skip to content

Commit 5565a76

Browse files
authored
Merge pull request swiftlang#36597 from DougGregor/loosen-key-paths-global-actors
Loosen key path restrictions for global actor-isolated properties.
2 parents 010068f + 070d13c commit 5565a76

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
@@ -1954,6 +1954,12 @@ namespace {
19541954
LLVM_FALLTHROUGH; // otherwise, perform checking
19551955

19561956
case ActorIsolationRestriction::GlobalActor:
1957+
// Disable global actor checking for now.
1958+
if (!ctx.LangOpts.isSwiftVersionAtLeast(6))
1959+
break;
1960+
1961+
LLVM_FALLTHROUGH; // otherwise, it's invalid so diagnose it.
1962+
19571963
case ActorIsolationRestriction::CrossActorSelf:
19581964
// 'let'-bound decls with this isolation are OK, just check them.
19591965
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)