@@ -198,26 +198,46 @@ func requireSendable<T: Sendable>(_: T) {}
198
198
@preconcurrency
199
199
struct RequireSendable < T: Sendable > { }
200
200
201
- class NotSendable { } // expected-note 4 {{class 'NotSendable' does not conform to the 'Sendable' protocol}}
201
+ class NotSendable { } // expected-note 8 {{class 'NotSendable' does not conform to the 'Sendable' protocol}}
202
202
203
203
class UnavailableSendable { }
204
204
205
205
@available ( * , unavailable)
206
206
extension UnavailableSendable : @unchecked Sendable { }
207
- // expected-note@-1 4 {{conformance of 'UnavailableSendable' to 'Sendable' has been explicitly marked unavailable here}}
207
+ // expected-note@-1 8 {{conformance of 'UnavailableSendable' to 'Sendable' has been explicitly marked unavailable here}}
208
208
209
209
typealias T = RequireSendable < NotSendable >
210
210
// expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
211
211
212
212
typealias T2 = RequireSendable < UnavailableSendable >
213
213
// expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
214
214
215
- func testRequirementDowngrade( ns: NotSendable , us: UnavailableSendable ) {
215
+ class C {
216
+ @preconcurrency
217
+ func requireSendable< T: Sendable > ( _: T ) { }
218
+
219
+ @preconcurrency
220
+ static func requireSendableStatic< T: Sendable > ( _: T ) { }
221
+ }
222
+
223
+ func testRequirementDowngrade( ns: NotSendable , us: UnavailableSendable , c: C ) {
216
224
requireSendable ( ns)
217
225
// expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
218
226
227
+ c. requireSendable ( ns)
228
+ // expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
229
+
230
+ C . requireSendableStatic ( ns)
231
+ // expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
232
+
219
233
requireSendable ( us)
220
234
// expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
235
+
236
+ c. requireSendable ( us)
237
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
238
+
239
+ C . requireSendableStatic ( us)
240
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
221
241
}
222
242
223
243
@@ -232,13 +252,33 @@ func requireSendableExistential(_: any P2 & Sendable) {}
232
252
233
253
func requireSendableExistentialAlways( _: any P2 & Sendable ) { }
234
254
235
- func testErasureDowngrade( ns: NotSendable , us: UnavailableSendable ) {
255
+ extension C {
256
+ @preconcurrency
257
+ func requireSendableExistential( _: any P2 & Sendable ) { }
258
+
259
+ @preconcurrency
260
+ static func requireSendableExistentialStatic( _: any P2 & Sendable ) { }
261
+ }
262
+
263
+ func testErasureDowngrade( ns: NotSendable , us: UnavailableSendable , c: C ) {
236
264
requireSendableExistential ( ns)
237
265
// expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
238
266
267
+ c. requireSendableExistential ( ns)
268
+ // expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
269
+
270
+ C . requireSendableExistentialStatic ( ns)
271
+ // expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
272
+
239
273
requireSendableExistential ( us)
240
274
// expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
241
275
276
+ c. requireSendableExistential ( us)
277
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
278
+
279
+ C . requireSendableExistentialStatic ( us)
280
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
281
+
242
282
withSendableClosure {
243
283
let ns = NotSendable ( )
244
284
requireSendableExistentialAlways ( ns)
0 commit comments