@@ -180,26 +180,46 @@ func requireSendable<T: Sendable>(_: T) {}
180
180
@preconcurrency
181
181
struct RequireSendable < T: Sendable > { }
182
182
183
- class NotSendable { } // expected-note 4 {{class 'NotSendable' does not conform to the 'Sendable' protocol}}
183
+ class NotSendable { } // expected-note 8 {{class 'NotSendable' does not conform to the 'Sendable' protocol}}
184
184
185
185
class UnavailableSendable { }
186
186
187
187
@available ( * , unavailable)
188
188
extension UnavailableSendable : @unchecked Sendable { }
189
- // expected-note@-1 4 {{conformance of 'UnavailableSendable' to 'Sendable' has been explicitly marked unavailable here}}
189
+ // expected-note@-1 8 {{conformance of 'UnavailableSendable' to 'Sendable' has been explicitly marked unavailable here}}
190
190
191
191
typealias T = RequireSendable < NotSendable >
192
192
// expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
193
193
194
194
typealias T2 = RequireSendable < UnavailableSendable >
195
195
// expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
196
196
197
- func testRequirementDowngrade( ns: NotSendable , us: UnavailableSendable ) {
197
+ class C {
198
+ @preconcurrency
199
+ func requireSendable< T: Sendable > ( _: T ) { }
200
+
201
+ @preconcurrency
202
+ static func requireSendableStatic< T: Sendable > ( _: T ) { }
203
+ }
204
+
205
+ func testRequirementDowngrade( ns: NotSendable , us: UnavailableSendable , c: C ) {
198
206
requireSendable ( ns)
199
207
// expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
200
208
209
+ c. requireSendable ( ns)
210
+ // expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
211
+
212
+ C . requireSendableStatic ( ns)
213
+ // expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
214
+
201
215
requireSendable ( us)
202
216
// expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
217
+
218
+ c. requireSendable ( us)
219
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
220
+
221
+ C . requireSendableStatic ( us)
222
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
203
223
}
204
224
205
225
@@ -214,13 +234,33 @@ func requireSendableExistential(_: any P2 & Sendable) {}
214
234
215
235
func requireSendableExistentialAlways( _: any P2 & Sendable ) { }
216
236
217
- func testErasureDowngrade( ns: NotSendable , us: UnavailableSendable ) {
237
+ extension C {
238
+ @preconcurrency
239
+ func requireSendableExistential( _: any P2 & Sendable ) { }
240
+
241
+ @preconcurrency
242
+ static func requireSendableExistentialStatic( _: any P2 & Sendable ) { }
243
+ }
244
+
245
+ func testErasureDowngrade( ns: NotSendable , us: UnavailableSendable , c: C ) {
218
246
requireSendableExistential ( ns)
219
247
// expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
220
248
249
+ c. requireSendableExistential ( ns)
250
+ // expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
251
+
252
+ C . requireSendableExistentialStatic ( ns)
253
+ // expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
254
+
221
255
requireSendableExistential ( us)
222
256
// expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
223
257
258
+ c. requireSendableExistential ( us)
259
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
260
+
261
+ C . requireSendableExistentialStatic ( us)
262
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
263
+
224
264
withSendableClosure {
225
265
let ns = NotSendable ( )
226
266
requireSendableExistentialAlways ( ns)
0 commit comments