Skip to content

Commit 508274c

Browse files
committed
Update "non-concurrent-value" diagnostics to say "non-sendable"
1 parent 9579390 commit 508274c

12 files changed

+59
-59
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4404,24 +4404,24 @@ ERROR(global_actor_isolated_requirement_witness_conflict,none,
44044404
(DescriptiveDeclKind, DeclName, Type, Identifier, Type))
44054405

44064406
WARNING(non_concurrent_param_type,none,
4407-
"cannot pass argument of non-concurrent-value type %0 across actors",
4407+
"cannot pass argument of non-sendable type %0 across actors",
44084408
(Type))
44094409
WARNING(non_concurrent_result_type,none,
4410-
"cannot call function returning non-concurrent-value type %0 across "
4410+
"cannot call function returning non-sendable type %0 across "
44114411
"actors", (Type))
44124412
WARNING(non_concurrent_property_type,none,
4413-
"cannot use %0 %1 with a non-concurrent-value type %2 "
4413+
"cannot use %0 %1 with a non-sendable type %2 "
44144414
"%select{across actors|from concurrently-executed code}3",
44154415
(DescriptiveDeclKind, DeclName, Type, bool))
44164416
WARNING(non_concurrent_keypath_capture,none,
4417-
"cannot form key path that captures non-concurrent-value type %0",
4417+
"cannot form key path that captures non-sendable type %0",
44184418
(Type))
44194419
WARNING(non_concurrent_keypath_access,none,
4420-
"cannot form key path that accesses non-concurrent-value type %0",
4420+
"cannot form key path that accesses non-sendable type %0",
44214421
(Type))
44224422
ERROR(non_concurrent_type_member,none,
44234423
"%select{stored property %1|associated value %1}0 of "
4424-
"'Sendable'-conforming %2 %3 has non-concurrent-value type %4",
4424+
"'Sendable'-conforming %2 %3 has non-sendable type %4",
44254425
(bool, DeclName, DescriptiveDeclKind, DeclName, Type))
44264426
ERROR(concurrent_value_class_mutable_property,none,
44274427
"stored property %0 of 'Sendable'-conforming %1 %2 is mutable",

include/swift/Option/FrontendOptions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ def enable_copy_propagation : Flag<["-"], "enable-copy-propagation">,
193193
def disable_copy_propagation : Flag<["-"], "disable-copy-propagation">,
194194
HelpText<"Don't run SIL copy propagation to preserve object lifetime.">;
195195

196-
def enable_infer_public_concurrent_value : Flag<["-"], "enable-infer-public-concurrent-value">,
196+
def enable_infer_public_concurrent_value : Flag<["-"], "enable-infer-public-sendable">,
197197
HelpText<"Enable inference of Sendable conformances for public structs and enums">;
198198

199-
def disable_infer_public_concurrent_value : Flag<["-"], "disable-infer-public-concurrent-value">,
199+
def disable_infer_public_concurrent_value : Flag<["-"], "disable-infer-public-sendable">,
200200
HelpText<"Disable inference of Sendable conformances for public structs and enums">;
201201

202202
} // end let Flags = [FrontendOption, NoDriverOption]

test/Concurrency/actor_call_implicitly_async.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,22 +177,22 @@ func blender(_ peeler : () -> Void) {
177177

178178

179179
await wisk({})
180-
// expected-warning@-1{{cannot pass argument of non-concurrent-value type 'Any' across actors}}
180+
// expected-warning@-1{{cannot pass argument of non-sendable type 'Any' across actors}}
181181
await wisk(1)
182-
// expected-warning@-1{{cannot pass argument of non-concurrent-value type 'Any' across actors}}
182+
// expected-warning@-1{{cannot pass argument of non-sendable type 'Any' across actors}}
183183
await (peelBanana)()
184184
await (((((peelBanana)))))()
185185
await (((wisk)))((wisk)((wisk)(1)))
186-
// expected-warning@-1 3{{cannot pass argument of non-concurrent-value type 'Any' across actors}}
186+
// expected-warning@-1 3{{cannot pass argument of non-sendable type 'Any' across actors}}
187187

188188
blender((peelBanana)) // expected-error {{global function 'peelBanana()' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
189189
await wisk(peelBanana) // expected-error {{global function 'peelBanana()' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
190-
// expected-warning@-1{{cannot pass argument of non-concurrent-value type 'Any' across actors}}
190+
// expected-warning@-1{{cannot pass argument of non-sendable type 'Any' across actors}}
191191

192192
await wisk(wisk) // expected-error {{global function 'wisk' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
193-
// expected-warning@-1{{cannot pass argument of non-concurrent-value type 'Any' across actors}}
193+
// expected-warning@-1{{cannot pass argument of non-sendable type 'Any' across actors}}
194194
await (((wisk)))(((wisk))) // expected-error {{global function 'wisk' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
195-
// expected-warning@-1{{cannot pass argument of non-concurrent-value type 'Any' across actors}}
195+
// expected-warning@-1{{cannot pass argument of non-sendable type 'Any' across actors}}
196196

197197
// expected-warning@+2 {{no 'async' operations occur within 'await' expression}}
198198
// expected-error@+1 {{global function 'wisk' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
@@ -240,18 +240,18 @@ actor Calculator {
240240

241241
@OrangeActor func doSomething() async {
242242
let _ = (await bananaAdd(1))(2)
243-
// expected-warning@-1{{cannot call function returning non-concurrent-value type}}
243+
// expected-warning@-1{{cannot call function returning non-sendable type}}
244244
let _ = await (await bananaAdd(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}
245-
// expected-warning@-1{{cannot call function returning non-concurrent-value type}}
245+
// expected-warning@-1{{cannot call function returning non-sendable type}}
246246

247247
let calc = Calculator()
248248

249249
let _ = (await calc.addCurried(1))(2)
250-
// expected-warning@-1{{cannot call function returning non-concurrent-value type}}
250+
// expected-warning@-1{{cannot call function returning non-sendable type}}
251251
let _ = await (await calc.addCurried(1))(2) // expected-warning{{no 'async' operations occur within 'await' expression}}
252-
// expected-warning@-1{{cannot call function returning non-concurrent-value type}}
252+
// expected-warning@-1{{cannot call function returning non-sendable type}}
253253

254254
let plusOne = await calc.addCurried(await calc.add(0, 1))
255-
// expected-warning@-1{{cannot call function returning non-concurrent-value type}}
255+
// expected-warning@-1{{cannot call function returning non-sendable type}}
256256
let _ = plusOne(2)
257257
}

test/Concurrency/actor_isolation.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func checkAsyncPropertyAccess() async {
9090

9191
act.text[0] += "hello" // expected-error{{actor-isolated property 'text' can only be mutated from inside the actor}}
9292

93-
_ = act.point // expected-warning{{cannot use property 'point' with a non-concurrent-value type 'Point' across actors}}
93+
_ = act.point // expected-warning{{cannot use property 'point' with a non-sendable type 'Point' across actors}}
9494
}
9595

9696
extension MyActor {
@@ -659,11 +659,11 @@ class SomeClassWithInits {
659659
func hasDetached() {
660660
Task.runDetached {
661661
// okay
662-
await self.isolated() // expected-warning{{cannot use parameter 'self' with a non-concurrent-value type 'SomeClassWithInits' from concurrently-executed code}}
663-
self.isolated() // expected-warning{{cannot use parameter 'self' with a non-concurrent-value type 'SomeClassWithInits' from concurrently-executed code}}
662+
await self.isolated() // expected-warning{{cannot use parameter 'self' with a non-sendable type 'SomeClassWithInits' from concurrently-executed code}}
663+
self.isolated() // expected-warning{{cannot use parameter 'self' with a non-sendable type 'SomeClassWithInits' from concurrently-executed code}}
664664
// expected-error@-1{{call is 'async' but is not marked with 'await'}}
665665

666-
print(await self.mutableState) // expected-warning{{cannot use parameter 'self' with a non-concurrent-value type 'SomeClassWithInits' from concurrently-executed code}}
666+
print(await self.mutableState) // expected-warning{{cannot use parameter 'self' with a non-sendable type 'SomeClassWithInits' from concurrently-executed code}}
667667
}
668668
}
669669
}

test/Concurrency/actor_keypath_isolation.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func tryKeyPathsMisc(d : Door) {
4747

4848
// in combination with other key paths
4949

50-
_ = (\Door.letBox).appending(path: // expected-warning {{cannot form key path that accesses non-concurrent-value type 'Box?'}}
50+
_ = (\Door.letBox).appending(path: // expected-warning {{cannot form key path that accesses non-sendable type 'Box?'}}
5151
\Box?.?.size)
5252

5353
_ = (\Door.varBox).appending(path: // expected-error {{cannot form key path to actor-isolated property 'varBox'}}
@@ -61,9 +61,9 @@ func tryKeyPathsFromAsync() async {
6161
}
6262

6363
func tryNonSendable() {
64-
_ = \Door.letDict[0] // expected-warning {{cannot form key path that accesses non-concurrent-value type '[Int : Box]'}}
64+
_ = \Door.letDict[0] // expected-warning {{cannot form key path that accesses non-sendable type '[Int : Box]'}}
6565
_ = \Door.varDict[0] // expected-error {{cannot form key path to actor-isolated property 'varDict'}}
66-
_ = \Door.letBox!.size // expected-warning {{cannot form key path that accesses non-concurrent-value type 'Box?'}}
66+
_ = \Door.letBox!.size // expected-warning {{cannot form key path that accesses non-sendable type 'Box?'}}
6767
}
6868

6969
func tryKeypaths() {

test/Concurrency/concurrent_value_checking.swift

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ actor A2 {
2222
}
2323

2424
func testActorCreation(value: NotConcurrent) {
25-
_ = A2(value: value) // expected-warning{{cannot pass argument of non-concurrent-value type 'NotConcurrent' across actors}}
25+
_ = A2(value: value) // expected-warning{{cannot pass argument of non-sendable type 'NotConcurrent' across actors}}
2626
}
2727

2828
extension A1 {
@@ -37,9 +37,9 @@ extension A1 {
3737
_ = await self.asynchronous(nil)
3838

3939
// Across to a different actor, so Sendable restriction is enforced.
40-
_ = other.localLet // expected-warning{{cannot use property 'localLet' with a non-concurrent-value type 'NotConcurrent' across actors}}
41-
_ = await other.synchronous() // expected-warning{{cannot call function returning non-concurrent-value type 'NotConcurrent?' across actors}}
42-
_ = await other.asynchronous(nil) // expected-warning{{cannot pass argument of non-concurrent-value type 'NotConcurrent?' across actors}}
40+
_ = other.localLet // expected-warning{{cannot use property 'localLet' with a non-sendable type 'NotConcurrent' across actors}}
41+
_ = await other.synchronous() // expected-warning{{cannot call function returning non-sendable type 'NotConcurrent?' across actors}}
42+
_ = await other.asynchronous(nil) // expected-warning{{cannot pass argument of non-sendable type 'NotConcurrent?' across actors}}
4343
}
4444
}
4545

@@ -67,9 +67,9 @@ func globalAsync(_: NotConcurrent?) async {
6767
}
6868

6969
func globalTest() async {
70-
let a = globalValue // expected-warning{{cannot use let 'globalValue' with a non-concurrent-value type 'NotConcurrent?' across actors}}
71-
await globalAsync(a) // expected-warning{{cannot pass argument of non-concurrent-value type 'NotConcurrent?' across actors}}
72-
await globalSync(a) // expected-warning{{cannot pass argument of non-concurrent-value type 'NotConcurrent?' across actors}}
70+
let a = globalValue // expected-warning{{cannot use let 'globalValue' with a non-sendable type 'NotConcurrent?' across actors}}
71+
await globalAsync(a) // expected-warning{{cannot pass argument of non-sendable type 'NotConcurrent?' across actors}}
72+
await globalSync(a) // expected-warning{{cannot pass argument of non-sendable type 'NotConcurrent?' across actors}}
7373
}
7474

7575
struct HasSubscript {
@@ -88,10 +88,10 @@ class ClassWithGlobalActorInits {
8888

8989
@MainActor
9090
func globalTestMain(nc: NotConcurrent) async {
91-
let a = globalValue // expected-warning{{cannot use let 'globalValue' with a non-concurrent-value type 'NotConcurrent?' across actors}}
92-
await globalAsync(a) // expected-warning{{cannot pass argument of non-concurrent-value type 'NotConcurrent?' across actors}}
93-
await globalSync(a) // expected-warning{{cannot pass argument of non-concurrent-value type 'NotConcurrent?' across actors}}
94-
_ = await ClassWithGlobalActorInits(nc) // expected-warning{{cannot pass argument of non-concurrent-value type 'NotConcurrent' across actors}}
91+
let a = globalValue // expected-warning{{cannot use let 'globalValue' with a non-sendable type 'NotConcurrent?' across actors}}
92+
await globalAsync(a) // expected-warning{{cannot pass argument of non-sendable type 'NotConcurrent?' across actors}}
93+
await globalSync(a) // expected-warning{{cannot pass argument of non-sendable type 'NotConcurrent?' across actors}}
94+
_ = await ClassWithGlobalActorInits(nc) // expected-warning{{cannot pass argument of non-sendable type 'NotConcurrent' across actors}}
9595
_ = await ClassWithGlobalActorInits()
9696
}
9797

@@ -117,7 +117,7 @@ func testConcurrency() {
117117
print(y) // okay
118118
}
119119
acceptConcurrent {
120-
print(x) // expected-warning{{cannot use let 'x' with a non-concurrent-value type 'NotConcurrent' from concurrently-executed code}}
120+
print(x) // expected-warning{{cannot use let 'x' with a non-sendable type 'NotConcurrent' from concurrently-executed code}}
121121
print(y) // expected-error{{reference to captured var 'y' in concurrently-executing code}}
122122
}
123123
}
@@ -135,7 +135,7 @@ class HasNC {
135135
}
136136

137137
func testKeyPaths(dict: [NC: Int], nc: NC) {
138-
_ = \HasNC.dict[nc] // expected-warning{{cannot form key path that captures non-concurrent-value type 'NC'}}
138+
_ = \HasNC.dict[nc] // expected-warning{{cannot form key path that captures non-sendable type 'NC'}}
139139
}
140140

141141

@@ -148,7 +148,7 @@ protocol AsyncProto {
148148

149149
extension A1: AsyncProto {
150150
// FIXME: Poor diagnostic.
151-
func asyncMethod(_: NotConcurrent) async { } // expected-warning{{cannot pass argument of non-concurrent-value type 'NotConcurrent' across actors}}
151+
func asyncMethod(_: NotConcurrent) async { } // expected-warning{{cannot pass argument of non-sendable type 'NotConcurrent' across actors}}
152152
}
153153

154154
protocol MainActorProto {
@@ -157,7 +157,7 @@ protocol MainActorProto {
157157

158158
class SomeClass: MainActorProto {
159159
@SomeGlobalActor
160-
func asyncMainMethod(_: NotConcurrent) async { } // expected-warning{{cannot pass argument of non-concurrent-value type 'NotConcurrent' across actors}}
160+
func asyncMainMethod(_: NotConcurrent) async { } // expected-warning{{cannot pass argument of non-sendable type 'NotConcurrent' across actors}}
161161
}
162162

163163
// ----------------------------------------------------------------------
@@ -183,19 +183,19 @@ func acceptConcurrentUnary<T>(_: @concurrent (T) -> T) { }
183183
func concurrentClosures<T>(_: T) {
184184
acceptConcurrentUnary { (x: T) in
185185
_ = x // ok
186-
acceptConcurrentUnary { _ in x } // expected-warning{{cannot use parameter 'x' with a non-concurrent-value type 'T' from concurrently-executed code}}
186+
acceptConcurrentUnary { _ in x } // expected-warning{{cannot use parameter 'x' with a non-sendable type 'T' from concurrently-executed code}}
187187
}
188188
}
189189

190190
// ----------------------------------------------------------------------
191191
// Sendable checking
192192
// ----------------------------------------------------------------------
193193
struct S1: Sendable {
194-
var nc: NotConcurrent // expected-error{{stored property 'nc' of 'Sendable'-conforming struct 'S1' has non-concurrent-value type 'NotConcurrent'}}
194+
var nc: NotConcurrent // expected-error{{stored property 'nc' of 'Sendable'-conforming struct 'S1' has non-sendable type 'NotConcurrent'}}
195195
}
196196

197197
struct S2<T>: Sendable {
198-
var nc: T // expected-error{{stored property 'nc' of 'Sendable'-conforming generic struct 'S2' has non-concurrent-value type 'T'}}
198+
var nc: T // expected-error{{stored property 'nc' of 'Sendable'-conforming generic struct 'S2' has non-sendable type 'T'}}
199199
}
200200

201201
struct S3<T> {
@@ -206,7 +206,7 @@ struct S3<T> {
206206
extension S3: Sendable where T: Sendable { }
207207

208208
enum E1: Sendable {
209-
case payload(NotConcurrent) // expected-error{{associated value 'payload' of 'Sendable'-conforming enum 'E1' has non-concurrent-value type 'NotConcurrent'}}
209+
case payload(NotConcurrent) // expected-error{{associated value 'payload' of 'Sendable'-conforming enum 'E1' has non-sendable type 'NotConcurrent'}}
210210
}
211211

212212
enum E2<T> {
@@ -216,7 +216,7 @@ enum E2<T> {
216216
extension E2: Sendable where T: Sendable { }
217217

218218
final class C1: Sendable {
219-
let nc: NotConcurrent? = nil // expected-error{{stored property 'nc' of 'Sendable'-conforming class 'C1' has non-concurrent-value type 'NotConcurrent?'}}
219+
let nc: NotConcurrent? = nil // expected-error{{stored property 'nc' of 'Sendable'-conforming class 'C1' has non-sendable type 'NotConcurrent?'}}
220220
var x: Int = 0 // expected-error{{stored property 'x' of 'Sendable'-conforming class 'C1' is mutable}}
221221
let i: Int = 0
222222
}
@@ -227,11 +227,11 @@ final class C2: Sendable {
227227

228228
class C3 { }
229229

230-
class C4: C3, UnsafeSendable {
230+
class C4: C3, UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
231231
var y: Int = 0 // okay
232232
}
233233

234-
class C5: UnsafeSendable {
234+
class C5: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
235235
var x: Int = 0 // okay
236236
}
237237

@@ -246,15 +246,15 @@ class C9: Sendable { } // expected-error{{non-final class 'C9' cannot conform to
246246
// ----------------------------------------------------------------------
247247
// UnsafeSendable disabling checking
248248
// ----------------------------------------------------------------------
249-
struct S11: UnsafeSendable {
249+
struct S11: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
250250
var nc: NotConcurrent // okay
251251
}
252252

253-
struct S12<T>: UnsafeSendable {
253+
struct S12<T>: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
254254
var nc: T // okay
255255
}
256256

257-
enum E11<T>: UnsafeSendable {
257+
enum E11<T>: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
258258
case payload(NotConcurrent) // okay
259259
case other(T) // okay
260260
}

test/Concurrency/concurrent_value_checking_objc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class B: NSObject, Sendable {
1616
class C { }
1717

1818
final class D: NSObject, Sendable {
19-
let c: C = C() // expected-error{{stored property 'c' of 'Sendable'-conforming class 'D' has non-concurrent-value type 'C'}}
19+
let c: C = C() // expected-error{{stored property 'c' of 'Sendable'-conforming class 'D' has non-sendable type 'C'}}
2020
}
2121

2222

test/Concurrency/concurrent_value_inference_public.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-typecheck-verify-swift -enable-infer-public-concurrent-value
1+
// RUN: %target-typecheck-verify-swift -enable-infer-public-sendable
22

33
func acceptCV<T: Sendable>(_: T) { }
44

test/Concurrency/concurrentfunction_capturediagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func testCaseTrivialValue4() {
8686
// expected-note @-8 {{capturing use}}
8787
}
8888

89-
class Klass: UnsafeSendable {
89+
class Klass: UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
9090
var next: Klass? = nil
9191
}
9292
func inoutUserKlass(_ k: inout Klass) {}

test/Inputs/clang-importer-sdk/swift-modules/Foundation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public struct URL : _ObjectiveCBridgeable {
221221
}
222222
}
223223

224-
extension NSError : Error, UnsafeSendable {
224+
extension NSError : Error, UnsafeSendable { // expected-warning{{'UnsafeSendable' is deprecated: Use @unchecked Sendable instead}}
225225
public var _domain: String { return domain }
226226
public var _code: Int { return code }
227227
}

0 commit comments

Comments
 (0)