Skip to content

Commit e561ac4

Browse files
committed
[Concurrency] Print full isolation information when diagnosing key path components
1 parent 9a529e9 commit e561ac4

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5410,8 +5410,8 @@ ERROR(concurrent_access_local,none,
54105410
"use of local %kind0 in concurrently-executing code",
54115411
(const ValueDecl *))
54125412
ERROR(actor_isolated_keypath_component,none,
5413-
"cannot form key path to%select{| distributed}0 actor-isolated %kind1",
5414-
(bool, const ValueDecl *))
5413+
"cannot form key path to %0 %kind1",
5414+
(ActorIsolation, const ValueDecl *))
54155415
ERROR(effectful_keypath_component,none,
54165416
"cannot form key path to %0 with 'throws' or 'async'",
54175417
(DescriptiveDeclKind))

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3382,7 +3382,7 @@ namespace {
33823382
{
33833383
auto diagnostic = ctx.Diags.diagnose(
33843384
component.getLoc(), diag::actor_isolated_keypath_component,
3385-
isolation.isDistributedActor(), decl);
3385+
isolation, decl);
33863386

33873387
if (isolation == ActorIsolation::ActorInstance)
33883388
diagnosed = true;

test/Concurrency/actor_keypath_isolation.swift

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

5959
func tryKeyPathsFromAsync() async {
6060
_ = \Door.unsafeGlobActor_immutable
61-
_ = \Door.unsafeGlobActor_mutable // expected-warning {{cannot form key path to actor-isolated property 'unsafeGlobActor_mutable'; this is an error in Swift 6}}
61+
_ = \Door.unsafeGlobActor_mutable // expected-warning {{cannot form key path to main actor-isolated property 'unsafeGlobActor_mutable'; this is an error in Swift 6}}
6262
}
6363

6464
func tryNonSendable() {
@@ -69,7 +69,7 @@ func tryNonSendable() {
6969

7070
func tryKeypaths() {
7171
_ = \Door.unsafeGlobActor_immutable
72-
_ = \Door.unsafeGlobActor_mutable // expected-warning {{cannot form key path to actor-isolated property 'unsafeGlobActor_mutable'; this is an error in Swift 6}}
72+
_ = \Door.unsafeGlobActor_mutable // expected-warning {{cannot form key path to main actor-isolated property 'unsafeGlobActor_mutable'; this is an error in Swift 6}}
7373

7474
_ = \Door.immutable
7575
_ = \Door.globActor_immutable
@@ -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-warning {{cannot form key path to actor-isolated property 'globActor_mutable'; this is an error in Swift 6}}
87+
_ = \Door.globActor_mutable // expected-warning {{cannot form key path to main actor-isolated property 'globActor_mutable'; this is an error in Swift 6}}
8888
_ = \Door.[0] // expected-error{{cannot form key path to actor-isolated subscript 'subscript(_:)'}}
89-
_ = \Door.["hello"] // expected-warning {{cannot form key path to actor-isolated subscript 'subscript(_:)'; this is an error in Swift 6}}
89+
_ = \Door.["hello"] // expected-warning {{cannot form key path to main actor-isolated subscript 'subscript(_:)'; this is an error in Swift 6}}
9090
}

test/Concurrency/actor_keypath_isolation_swift6.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 // expected-error {{cannot form key path to main actor-isolated property 'unsafeGlobActor_mutable'}}
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 // expected-error {{cannot form key path to main actor-isolated property 'unsafeGlobActor_mutable'}}
7272

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

86-
_ = \Door.globActor_mutable // expected-error{{cannot form key path to actor-isolated property 'globActor_mutable'}}
86+
_ = \Door.globActor_mutable // expected-error{{cannot form key path to main actor-isolated property 'globActor_mutable'}}
8787
_ = \Door.[0] // expected-error{{cannot form key path to actor-isolated subscript 'subscript(_:)'}}
88-
_ = \Door.["hello"] // expected-error {{cannot form key path to actor-isolated subscript 'subscript(_:)'}}
88+
_ = \Door.["hello"] // expected-error {{cannot form key path to main actor-isolated subscript 'subscript(_:)'}}
8989
}

test/Concurrency/sendable_keypaths.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ func testGlobalActorIsolatedReferences() {
147147
}
148148

149149
let dataKP = \Isolated.data
150-
// expected-warning@-1 {{cannot form key path to actor-isolated property 'data'; this is an error in Swift 6}}
150+
// expected-warning@-1 {{cannot form key path to main actor-isolated property 'data'; this is an error in Swift 6}}
151151
let subscriptKP = \Isolated.[42]
152-
// expected-warning@-1 {{cannot form key path to actor-isolated subscript 'subscript(_:)'; this is an error in Swift 6}}
152+
// expected-warning@-1 {{cannot form key path to main actor-isolated subscript 'subscript(_:)'; this is an error in Swift 6}}
153153

154154
let _: KeyPath<Isolated, Int> & Sendable = dataKP
155155
// expected-warning@-1 {{type 'WritableKeyPath<Isolated, Int>' does not conform to the 'Sendable' protocol}}
@@ -158,7 +158,7 @@ func testGlobalActorIsolatedReferences() {
158158

159159
func testNonIsolated() {
160160
_ = \Isolated.data
161-
// expected-warning@-1 {{cannot form key path to actor-isolated property 'data'; this is an error in Swift 6}}
161+
// expected-warning@-1 {{cannot form key path to main actor-isolated property 'data'; this is an error in Swift 6}}
162162
}
163163

164164
@MainActor func testIsolated() {
@@ -189,13 +189,13 @@ func testReferencesToDifferentGlobalActorIsolatedMembers() {
189189
@MainActor func testIsolatedToMain() {
190190
_ = \Info.name // Ok
191191
_ = \Isolated.info.name
192-
// expected-warning@-1 {{cannot form key path to actor-isolated property 'info'; this is an error in Swift 6}}
192+
// expected-warning@-1 {{cannot form key path to global actor 'GlobalActor'-isolated property 'info'; this is an error in Swift 6}}
193193
}
194194

195195
@GlobalActor func testIsolatedToCustom() {
196196
_ = \Info.name // Ok
197-
// expected-warning@-1 {{cannot form key path to actor-isolated property 'name'; this is an error in Swift 6}}
197+
// expected-warning@-1 {{cannot form key path to main actor-isolated property 'name'; this is an error in Swift 6}}
198198
_ = \Isolated.info.name
199-
// expected-warning@-1 {{cannot form key path to actor-isolated property 'name'; this is an error in Swift 6}}
199+
// expected-warning@-1 {{cannot form key path to main actor-isolated property 'name'; this is an error in Swift 6}}
200200
}
201201
}

0 commit comments

Comments
 (0)