You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Concurrency] Split up the non-Sendable argument diagnostics and improve
wording.
Splitting up the diagnostic into separate diagnostics based on the reference
kind is easier for me to read. The wording of the error message now puts
the problem -- crossing an isolation boundary -- at the center of the message,
and attempts to clarify how the value crosses an isolation boundary. E.g. for
the witness diagnostics, the value crosses an isolation boundary when calling
the witness through the protocol requirement in generic code.
This change does not add any additional information to the diagnostics, but it'd
be valuable to show both the source and destination isolation.
Copy file name to clipboardExpand all lines: test/Concurrency/actor_inout_isolation.swift
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -119,7 +119,7 @@ extension TestActor {
119
119
func passStateIntoDifferentClassMethod()async{
120
120
letother=NonAsyncClass()
121
121
letotherCurry= other.modifyOtherAsync
122
-
// expected-targeted-complete-tns-warning @-1 {{non-sendable type 'NonAsyncClass' exiting actor-isolated context in call to nonisolated instance method 'modifyOtherAsync' cannot cross actor boundary}}
122
+
// expected-targeted-complete-tns-warning @-1 {{non-sendable type 'NonAsyncClass' cannot exit actor-isolated context in call to nonisolated instance method 'modifyOtherAsync'}}
123
123
await other.modifyOtherAsync(&value2)
124
124
// expected-error @-1 {{actor-isolated property 'value2' cannot be passed 'inout' to 'async' function call}}
125
125
@@ -288,11 +288,11 @@ actor ProtectArray {
288
288
func test()async{
289
289
// FIXME: this is invalid too!
290
290
_ =await array.mutateAsynchronously
291
-
// expected-targeted-complete-tns-warning@-1 {{non-sendable type '@lvalue [Int]' exiting actor-isolated context in call to nonisolated property 'mutateAsynchronously' cannot cross actor boundary}}
291
+
// expected-targeted-complete-tns-warning@-1 {{non-sendable type '@lvalue [Int]' cannot exit actor-isolated context in call to nonisolated property 'mutateAsynchronously'}}
292
292
293
293
_ =awaitarray[mutateAsynchronously:0]
294
294
// expected-error@-1 {{actor-isolated property 'array' cannot be passed 'inout' to 'async' function call}}
295
-
// expected-targeted-complete-tns-warning@-2 {{non-sendable type 'inout Array<Int>' exiting actor-isolated context in call to nonisolated subscript 'subscript(mutateAsynchronously:)' cannot cross actor boundary}}
295
+
// expected-targeted-complete-tns-warning@-2 {{non-sendable type 'inout Array<Int>' cannot exit actor-isolated context in call to nonisolated subscript 'subscript(mutateAsynchronously:)'}}
_ =await ext.point // expected-warning {{non-sendable type 'Point' in implicitly asynchronous access to main actor-isolated property 'point' cannot cross actor boundary}}
155
155
_ =await anno.point // expected-warning {{non-sendable type 'Point' in implicitly asynchronous access to global actor 'SomeGlobalActor'-isolated property 'point' cannot cross actor boundary}}
156
-
// expected-warning@-1 {{non-sendable type 'NoGlobalActorValueType' passed in implicitly asynchronous call to global actor 'SomeGlobalActor'-isolated property 'point' cannot cross actor boundary}}
156
+
// expected-warning@-1 {{non-sendable type 'NoGlobalActorValueType' cannot be sent into global actor 'SomeGlobalActor'-isolated context in call to property 'point'}}
157
157
158
158
_ = formance.counter
159
159
_ = anno.counter
160
160
161
161
// these will always need an await
162
-
_ =await(formance asMainCounter).counter // expected-warning {{non-sendable type 'any MainCounter' passed in implicitly asynchronous call to main actor-isolated property 'counter' cannot cross actor boundary}}
162
+
_ =await(formance asMainCounter).counter // expected-warning {{non-sendable type 'any MainCounter' cannot be sent into main actor-isolated context in call to property 'counter'}}
163
163
_ =awaitext[1]
164
164
_ =await formance.ticker
165
165
_ =await ext.polygon // expected-warning {{non-sendable type '[Point]' in implicitly asynchronous access to main actor-isolated property 'polygon' cannot cross actor boundary}}
@@ -1662,7 +1662,7 @@ actor SafeMutatingCall {
1662
1662
1663
1663
1664
1664
@MainActor
1665
-
functestLocalFunctoinIsolation(){
1665
+
functestLocalFunctionIsolation(){
1666
1666
func isolatedLocalFn(){}
1667
1667
// expected-note@-1 {{calls to local function 'isolatedLocalFn()' from outside of its actor context are implicitly asynchronous}}
1668
1668
// expected-note@-2 {{main actor isolation inferred from enclosing context}}
// these do need await, regardless of reference or value type
67
67
_ =await(formance asanyMainCounter).counter
68
-
// expected-error@-1 {{non-sendable type 'any MainCounter' passed in implicitly asynchronous call to main actor-isolated property 'counter' cannot cross actor boundary}}
68
+
// expected-error@-1 {{non-sendable type 'any MainCounter' cannot be sent into main actor-isolated context in call to property 'counter'}}
Copy file name to clipboardExpand all lines: test/Concurrency/concurrent_value_checking.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -270,7 +270,7 @@ protocol AsyncProto {
270
270
}
271
271
272
272
extensionA1:AsyncProto{
273
-
func asyncMethod(_:NotConcurrent)async{} // expected-warning{{non-sendable type 'NotConcurrent' in parameter of the protocol requirement satisfied by actor-isolated instance method 'asyncMethod' cannot cross actor boundary}}
273
+
func asyncMethod(_:NotConcurrent)async{} // expected-warning{{non-sendable parameter type 'NotConcurrent' cannot be sent from protocol requirement 'asyncMethod' into actor-isolated implementation}}
274
274
}
275
275
276
276
protocolMainActorProto{
@@ -279,7 +279,7 @@ protocol MainActorProto {
279
279
280
280
classSomeClass:MainActorProto{
281
281
@SomeGlobalActor
282
-
func asyncMainMethod(_:NotConcurrent)async{} // expected-warning{{non-sendable type 'NotConcurrent' in parameter of the protocol requirement satisfied by global actor 'SomeGlobalActor'-isolated instance method 'asyncMainMethod' cannot cross actor boundary}}
282
+
func asyncMainMethod(_:NotConcurrent)async{} // expected-warning{{non-sendable parameter type 'NotConcurrent' cannot be sent from protocol requirement 'asyncMainMethod' into global actor 'SomeGlobalActor'-isolated implementation}}
returnawait x.counter // expected-error {{non-sendable type 'MySerializedStruct' passed in implicitly asynchronous call to main actor-isolated property 'counter' cannot cross actor boundary}}
17
+
returnawait x.counter // expected-error {{non-sendable type 'MySerializedStruct' cannot be sent into main actor-isolated context in call to property 'counter'}}
Copy file name to clipboardExpand all lines: test/Concurrency/sendable_checking.swift
+10-10Lines changed: 10 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -142,12 +142,12 @@ protocol P {
142
142
func foo(x :()->())->(){}
143
143
144
144
func bar(x :()->())->(){}
145
-
// expected-warning@-1 {{non-sendable type '() -> ()' in parameter of the protocol requirement satisfied by actor-isolated instance method 'bar(x:)' cannot cross actor boundary}}
145
+
// expected-warning@-1 {{non-sendable parameter type '() -> ()' cannot be sent from protocol requirement 'bar(x:)' into actor-isolated implementation}}
146
146
147
147
func foo2<T>(x :T)->(){}
148
148
149
149
func bar2<T>(x :T)->(){}
150
-
// expected-warning@-1 {{non-sendable type 'T' in parameter of the protocol requirement satisfied by actor-isolated instance method 'bar2(x:)' cannot cross actor boundary}}
150
+
// expected-warning@-1 {{non-sendable parameter type 'T' cannot be sent from protocol requirement 'bar2(x:)' into actor-isolated implementation}}
151
151
}
152
152
153
153
@available(SwiftStdlib 5.1,*)
@@ -174,12 +174,12 @@ class Sub : Super {
174
174
overridenonisolatedfunc foo(x :()->())async{}
175
175
176
176
overridenonisolatedfunc bar(x :()->())async{}
177
-
// expected-warning@-1 {{non-sendable type '() -> ()' in parameter of superclass method overridden by nonisolated instance method 'bar(x:)' cannot cross actor boundary}}
177
+
// expected-warning@-1 {{non-sendable parameter type '() -> ()' cannot be sent from superclass instance method 'bar(x:)' into nonisolated override}}
178
178
179
179
overridenonisolatedfunc foo2<T>(x:T)async{}
180
180
181
181
overridenonisolatedfunc bar2<T>(x:T)async{}
182
-
// expected-warning@-1 {{non-sendable type 'T' in parameter of superclass method overridden by nonisolated instance method 'bar2(x:)' cannot cross actor boundary}}
182
+
// expected-warning@-1 {{non-sendable parameter type 'T' cannot be sent from superclass instance method 'bar2(x:)' into nonisolated override}}
183
183
}
184
184
185
185
@available(SwiftStdlib 5.1,*)
@@ -216,8 +216,8 @@ class SuperWUnsafeSubscript {
216
216
classSubWUnsafeSubscript:SuperWUnsafeSubscript{
217
217
overridenonisolated subscript<T>(x :T)->Int{
218
218
get async{
219
-
// expected-warning@-2{{non-sendable type 'T' in parameter of superclass method overridden by nonisolated subscript 'subscript(_:)' cannot cross actor boundary}}
220
-
// expected-warning@-2{{non-sendable type 'T' in parameter of superclass method overridden by nonisolated getter for subscript 'subscript(_:)' cannot cross actor boundary}}
219
+
// expected-warning@-2{{non-sendable parameter type 'T' cannot be sent from superclass subscript 'subscript(_:)' into nonisolated override}}
220
+
// expected-warning@-2{{non-sendable parameter type 'T' cannot be sent from superclass getter for subscript 'subscript(_:)' into nonisolated override}}
221
221
// there really shouldn't be two warnings produced here, see rdar://110846040 (Sendable diagnostics reported twice for subscript getters)
222
222
return0
223
223
}
@@ -269,10 +269,10 @@ final class NonSendable {
269
269
// expected-tns-note @-2 {{sending task-isolated 'self' to main actor-isolated instance method 'update()' risks causing data races between main actor-isolated and task-isolated uses}}
270
270
271
271
_ =await x
272
-
// expected-warning@-1 {{non-sendable type 'NonSendable' passed in implicitly asynchronous call to main actor-isolated property 'x' cannot cross actor boundary}}
272
+
// expected-warning@-1 {{non-sendable type 'NonSendable' cannot be sent into main actor-isolated context in call to property 'x'}}
273
273
274
274
_ =awaitself.x
275
-
// expected-warning@-1 {{non-sendable type 'NonSendable' passed in implicitly asynchronous call to main actor-isolated property 'x' cannot cross actor boundary}}
275
+
// expected-warning@-1 {{non-sendable type 'NonSendable' cannot be sent into main actor-isolated context in call to property 'x'}}
// expected-tns-note @-2 {{sending 't' to main actor-isolated instance method 'update()' risks causing data races between main actor-isolated and local nonisolated uses}}
295
295
296
296
_ =await t.x
297
-
// expected-warning @-1 {{non-sendable type 'NonSendable' passed in implicitly asynchronous call to main actor-isolated property 'x' cannot cross actor boundary}}
297
+
// expected-warning @-1 {{non-sendable type 'NonSendable' cannot be sent into main actor-isolated context in call to property 'x'}}
298
298
// expected-tns-note @-2 {{access can happen concurrently}}
// expected-tns-note @-4 {{sending 't' to main actor-isolated instance method 'update()' risks causing data races between main actor-isolated and local nonisolated uses}}
310
310
311
311
_ =await t.y
312
-
// expected-warning @-1 {{non-sendable type 'NonSendable' passed in implicitly asynchronous call to global actor 'CustomActor'-isolated property 'y' cannot cross actor boundary}}
312
+
// expected-warning @-1 {{non-sendable type 'NonSendable' cannot be sent into global actor 'CustomActor'-isolated context in call to property 'y'}}
313
313
// expected-tns-note @-2 {{access can happen concurrently}}
Copy file name to clipboardExpand all lines: test/Concurrency/sendable_override_checking.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -24,10 +24,10 @@ class Super {
24
24
@available(SwiftStdlib 5.1,*)
25
25
classSub:Super{
26
26
@MainActoroverridefunc f(_:NotSendable)async{}
27
-
// expected-warning@-1{{non-sendable type 'NotSendable' in parameter of superclass method overridden by main actor-isolated instance method 'f' cannot cross actor boundary}}
27
+
// expected-warning@-1{{non-sendable parameter type 'NotSendable' cannot be sent from superclass instance method 'f' into main actor-isolated override}}
// expected-warning@-1{{non-sendable type 'NotSendable' in parameter of superclass method overridden by nonisolated instance method 'g2' cannot cross actor boundary}}
32
+
// expected-warning@-1{{non-sendable parameter type 'NotSendable' cannot be sent from superclass instance method 'g2' into nonisolated override}}
0 commit comments