Skip to content

Commit 05dc4b5

Browse files
committed
[Concurrency] Print full isolation information when diagnosing key path components
1 parent db78455 commit 05dc4b5

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
@@ -155,9 +155,9 @@ func testGlobalActorIsolatedReferences() {
155155
}
156156

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

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

167167
func testNonIsolated() {
168168
_ = \Isolated.data
169-
// expected-warning@-1 {{cannot form key path to actor-isolated property 'data'; this is an error in Swift 6}}
169+
// expected-warning@-1 {{cannot form key path to main actor-isolated property 'data'; this is an error in Swift 6}}
170170
}
171171

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

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

0 commit comments

Comments
 (0)