@@ -182,31 +182,52 @@ struct RequireSendable<T: Sendable> {}
182
182
183
183
class NotSendable { } // expected-note 4 {{class 'NotSendable' does not conform to the 'Sendable' protocol}}
184
184
185
+ class UnavailableSendable { }
186
+
187
+ @available ( * , unavailable)
188
+ extension UnavailableSendable : @unchecked Sendable { }
189
+ // expected-note@-1 4 {{conformance of 'UnavailableSendable' to 'Sendable' has been explicitly marked unavailable here}}
190
+
185
191
typealias T = RequireSendable < NotSendable >
186
192
// expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
187
193
188
- func testRequirementDowngrade( ns: NotSendable ) {
194
+ typealias T2 = RequireSendable < UnavailableSendable >
195
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
196
+
197
+ func testRequirementDowngrade( ns: NotSendable , us: UnavailableSendable ) {
189
198
requireSendable ( ns)
190
199
// expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
200
+
201
+ requireSendable ( us)
202
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
191
203
}
192
204
193
205
194
206
protocol P2 { }
195
207
196
208
extension NotSendable : P2 { }
197
209
210
+ extension UnavailableSendable : P2 { }
211
+
198
212
@preconcurrency
199
213
func requireSendableExistential( _: any P2 & Sendable ) { }
200
214
201
215
func requireSendableExistentialAlways( _: any P2 & Sendable ) { }
202
216
203
- func testErasureDowngrade( ns: NotSendable ) {
217
+ func testErasureDowngrade( ns: NotSendable , us : UnavailableSendable ) {
204
218
requireSendableExistential ( ns)
205
219
// expected-warning@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
206
220
221
+ requireSendableExistential ( us)
222
+ // expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
223
+
207
224
withSendableClosure {
208
225
let ns = NotSendable ( )
209
226
requireSendableExistentialAlways ( ns)
210
227
// expected-error@-1 {{type 'NotSendable' does not conform to the 'Sendable' protocol}}
228
+
229
+ let us = UnavailableSendable ( )
230
+ requireSendableExistentialAlways ( us)
231
+ // expected-error@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable}}
211
232
}
212
233
}
0 commit comments