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
structNS2{ // expected-note {{consider making struct 'NS2' conform to the 'Sendable' protocol}}
18
-
// expected-complete-and-tns-note @-1 {{consider making struct 'NS2' conform to the 'Sendable' protocol}}
20
+
// expected-tns-note @-1 {{consider making struct 'NS2' conform to the 'Sendable' protocol}}
19
21
varns1:NS1
20
22
}
21
23
@@ -27,7 +29,7 @@ extension NS3: Sendable { }
27
29
28
30
@available(SwiftStdlib 5.1,*)
29
31
classNS4{} // expected-note {{class 'NS4' does not conform to the 'Sendable' protocol}}
30
-
// expected-complete-and-tns-note @-1 {{class 'NS4' does not conform to the 'Sendable' protocol}}
32
+
// expected-tns-note @-1 {{class 'NS4' does not conform to the 'Sendable' protocol}}
31
33
32
34
@available(SwiftStdlib 5.1,*)
33
35
func acceptCV<T:Sendable>(_:T){}
@@ -44,15 +46,15 @@ func testCV(
44
46
45
47
acceptCV(ns1array) // expected-warning {{conformance of 'NS1' to 'Sendable' is unavailable}}
46
48
47
-
acceptCV(ns2) // expected-complete-and-tns-warning {{type 'NS2' does not conform to the 'Sendable' protocol}}
49
+
acceptCV(ns2) // expected-tns-warning {{type 'NS2' does not conform to the 'Sendable' protocol}}
48
50
49
51
acceptCV(ns3) // expected-warning {{conformance of 'NS3' to 'Sendable' is only available in macOS 11.0 or newer}}
50
52
// expected-note @-1 {{add 'if #available' version check}}
51
53
52
-
acceptCV(ns4) // expected-complete-and-tns-warning {{type 'NS4' does not conform to the 'Sendable' protocol}}
54
+
acceptCV(ns4) // expected-tns-warning {{type 'NS4' does not conform to the 'Sendable' protocol}}
53
55
54
-
acceptCV(fn) // expected-complete-and-tns-warning {{type '() -> Void' does not conform to the 'Sendable' protocol}}
55
-
// expected-complete-and-tns-note @-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
56
+
acceptCV(fn) // expected-tns-warning {{type '() -> Void' does not conform to the 'Sendable' protocol}}
57
+
// expected-tns-note @-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
56
58
57
59
acceptSendableFn(fn) // expected-warning{{passing non-Sendable parameter 'fn' to function expecting a '@Sendable' closure}}
58
60
}
@@ -93,8 +95,8 @@ public actor MyActor: MyProto {
93
95
94
96
func g(ns1:NS1)async{
95
97
awaitnonisolatedAsyncFunc1(ns1)
96
-
// expected-tns-warning @-1 {{sending 'ns1' risks causing data races}}
97
-
// expected-tns-note @-2 {{sending 'self'-isolated 'ns1' to nonisolated global function 'nonisolatedAsyncFunc1' risks causing data races between nonisolated and 'self'-isolated uses}}
98
+
// expected-tns-ni-warning @-1 {{sending 'ns1' risks causing data races}}
99
+
// expected-tns-ni-note @-2 {{sending 'self'-isolated 'ns1' to nonisolated global function 'nonisolatedAsyncFunc1' risks causing data races between nonisolated and 'self'-isolated uses}}
98
100
_ =awaitnonisolatedAsyncFunc2()
99
101
}
100
102
}
@@ -162,18 +164,18 @@ class Super {
162
164
163
165
@MainActor
164
166
func bar (x :()->())async{}
165
-
// expected-note@-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
167
+
// expected-targeted-and-ni-note@-1 {{a function type must be marked '@Sendable' to conform to 'Sendable'}}
166
168
167
169
@MainActor
168
170
func foo2<T :Sendable>(x:T)async{}
169
171
170
172
@MainActor
171
173
func bar2<T>(x:T)async{}
172
-
// expected-note@-1 {{consider making generic parameter 'T' conform to the 'Sendable' protocol}} {{14-14=: Sendable}}
174
+
// expected-targeted-and-ni-note@-1 {{consider making generic parameter 'T' conform to the 'Sendable' protocol}} {{14-14=: Sendable}}
173
175
174
176
@MainActor
175
177
func bar3<T:Equatable>(x:T)async{}
176
-
// expected-note@-1 {{consider making generic parameter 'T' conform to the 'Sendable' protocol}} {{25-25= & Sendable}}
178
+
// expected-targeted-and-ni-note@-1 {{consider making generic parameter 'T' conform to the 'Sendable' protocol}} {{25-25= & Sendable}}
177
179
}
178
180
179
181
// Make sure isolation crossing overrides check sendability
@@ -182,16 +184,25 @@ class Super {
182
184
classSub:Super{
183
185
overridenonisolatedfunc foo(x :()->())async{}
184
186
187
+
// We do not emit an error for the override with
188
+
// NonisolatedNonsendingByDefault since the vtable thunk passes in MainActor
189
+
// so we are still in the main actor even though we are nonisolated. In the
190
+
// case of that being disabled, we cannot do this since we will hop off the
191
+
// actor.
185
192
overridenonisolatedfunc bar(x :()->())async{}
186
-
// expected-warning@-1 {{non-Sendable parameter type '() -> ()' cannot be sent from caller of superclass instance method 'bar(x:)' into nonisolated override}}
193
+
// expected-targeted-and-ni-warning@-1 {{non-Sendable parameter type '() -> ()' cannot be sent from caller of superclass instance method 'bar(x:)' into nonisolated override}}
187
194
188
195
overridenonisolatedfunc foo2<T>(x:T)async{}
189
196
197
+
// See comment above about why nonisolated overrides of superclass are allowed
198
+
// when is enabled NonisolatedNonsendingByDefault.
190
199
overridenonisolatedfunc bar2<T>(x:T)async{}
191
-
// expected-warning@-1 {{non-Sendable parameter type 'T' cannot be sent from caller of superclass instance method 'bar2(x:)' into nonisolated override}}
200
+
// expected-targeted-and-ni-warning@-1 {{non-Sendable parameter type 'T' cannot be sent from caller of superclass instance method 'bar2(x:)' into nonisolated override}}
192
201
202
+
// See comment above about why nonisolated overrides of superclass are allowed
203
+
// when is enabled NonisolatedNonsendingByDefault.
193
204
overridenonisolatedfunc bar3<T>(x:T)async{}
194
-
// expected-warning@-1 {{non-Sendable parameter type 'T' cannot be sent from caller of superclass instance method 'bar3(x:)' into nonisolated override}}
205
+
// expected-targeted-and-ni-warning@-1 {{non-Sendable parameter type 'T' cannot be sent from caller of superclass instance method 'bar3(x:)' into nonisolated override}}
195
206
}
196
207
197
208
@available(SwiftStdlib 5.1,*)
@@ -217,7 +228,8 @@ class SubWSafeSubscript : SuperWSafeSubscript {
217
228
classSuperWUnsafeSubscript{
218
229
@MainActor
219
230
subscript<T>(x :T)->Int{
220
-
// expected-note@-1 2{{consider making generic parameter 'T' conform to the 'Sendable' protocol}}
231
+
// expected-targeted-and-ni-note @-1 {{consider making generic parameter 'T' conform to the 'Sendable' protocol}}
232
+
// expected-targeted-and-ni-note @-2 {{consider making generic parameter 'T' conform to the 'Sendable' protocol}}
221
233
get async{
222
234
return0
223
235
}
@@ -226,10 +238,15 @@ class SuperWUnsafeSubscript {
226
238
227
239
@available(SwiftStdlib 5.1,*)
228
240
classSubWUnsafeSubscript:SuperWUnsafeSubscript{
241
+
// We do not emit an error for the override with
242
+
// NonisolatedNonsendingByDefault since the vtable thunk passes in MainActor
243
+
// so we are still in the main actor even though we are nonisolated. In the
244
+
// case of that being disabled, we cannot do this since we will hop off the
245
+
// actor.
229
246
overridenonisolated subscript<T>(x :T)->Int{
230
247
get async{
231
-
// expected-warning@-2{{non-Sendable parameter type 'T' cannot be sent from caller of superclass subscript 'subscript(_:)' into nonisolated override}}
232
-
// expected-warning@-2{{non-Sendable parameter type 'T' cannot be sent from caller of superclass getter for subscript 'subscript(_:)' into nonisolated override}}
248
+
// expected-targeted-and-ni-warning@-2{{non-Sendable parameter type 'T' cannot be sent from caller of superclass subscript 'subscript(_:)' into nonisolated override}}
249
+
// expected-targeted-and-ni-warning@-2{{non-Sendable parameter type 'T' cannot be sent from caller of superclass getter for subscript 'subscript(_:)' into nonisolated override}}
233
250
// there really shouldn't be two warnings produced here, see rdar://110846040 (Sendable diagnostics reported twice for subscript getters)
234
251
return0
235
252
}
@@ -263,7 +280,7 @@ struct CustomActor {
263
280
finalclassNonSendable{
264
281
// expected-note @-1 5 {{class 'NonSendable' does not conform to the 'Sendable' protocol}}
265
282
// TransferNonSendable emits 3 fewer errors here.
266
-
// expected-complete-and-tns-note @-3 {{class 'NonSendable' does not conform to the 'Sendable' protocol}}
283
+
// expected-tns-note @-3 {{class 'NonSendable' does not conform to the 'Sendable' protocol}}
// expected-tns-warning @-1 {{sending 'ns' risks causing data races}}
352
-
// expected-tns-note @-2 {{sending main actor-isolated 'ns' to nonisolated callee risks causing data races between nonisolated and main actor-isolated uses}}
369
+
// expected-tns-ni-warning @-1 {{sending 'ns' risks causing data races}}
370
+
// expected-tns-ni-note @-2 {{sending main actor-isolated 'ns' to nonisolated callee risks causing data races between nonisolated and main actor-isolated uses}}
// expected-tns-warning @-1 {{sending 'ns' risks causing data races}}
357
-
// expected-tns-note @-2 {{sending main actor-isolated 'ns' to nonisolated callee risks causing data races between nonisolated and main actor-isolated uses}}
374
+
// expected-tns-ni-warning @-1 {{sending 'ns' risks causing data races}}
375
+
// expected-tns-ni-note @-2 {{sending main actor-isolated 'ns' to nonisolated callee risks causing data races between nonisolated and main actor-isolated uses}}
358
376
}
377
+
#endif
359
378
360
379
@available(SwiftStdlib 5.1,*)
361
380
func testLocalCaptures(){
@@ -364,7 +383,7 @@ func testLocalCaptures() {
364
383
@Sendable
365
384
func a2()->NonSendable{
366
385
return ns
367
-
// expected-complete-and-tns-warning @-1 {{capture of 'ns' with non-Sendable type 'NonSendable' in a '@Sendable' local function}}
386
+
// expected-tns-warning @-1 {{capture of 'ns' with non-Sendable type 'NonSendable' in a '@Sendable' local function}}
0 commit comments