@@ -106,7 +106,7 @@ extension Test {
106
106
/// - Warning: This function is used to implement the `@Suite` macro. Do not
107
107
/// call it directly.
108
108
public static func __type(
109
- _ containingType: Any . Type ,
109
+ _ containingType: any ~ Copyable . Type,
110
110
displayName: String ? = nil ,
111
111
traits: [ any SuiteTrait ] ,
112
112
sourceLocation: SourceLocation
@@ -159,15 +159,21 @@ extension Test {
159
159
/// call it directly.
160
160
public static func __function(
161
161
named testFunctionName: String ,
162
- in containingType: Any . Type ? ,
162
+ in containingType: ( any ~ Copyable . Type) ? ,
163
163
xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
164
164
displayName: String ? = nil ,
165
165
traits: [ any TestTrait ] ,
166
166
sourceLocation: SourceLocation ,
167
167
parameters: [ __Parameter ] = [ ] ,
168
168
testFunction: @escaping @Sendable ( ) async throws -> Void
169
169
) -> Self {
170
- let containingTypeInfo = containingType. map ( TypeInfo . init ( describing: ) )
170
+ // Don't use Optional.map here due to a miscompile/crash. Expand out to an
171
+ // if expression instead. SEE: rdar://134280902
172
+ let containingTypeInfo : TypeInfo ? = if let containingType {
173
+ TypeInfo ( describing: containingType)
174
+ } else {
175
+ nil
176
+ }
171
177
let caseGenerator = { @Sendable in Case . Generator ( testFunction: testFunction) }
172
178
return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: [ ] )
173
179
}
@@ -235,7 +241,7 @@ extension Test {
235
241
/// call it directly.
236
242
public static func __function< C> (
237
243
named testFunctionName: String ,
238
- in containingType: Any . Type ? ,
244
+ in containingType: ( any ~ Copyable . Type) ? ,
239
245
xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
240
246
displayName: String ? = nil ,
241
247
traits: [ any TestTrait ] ,
@@ -244,7 +250,11 @@ extension Test {
244
250
parameters paramTuples: [ __Parameter ] ,
245
251
testFunction: @escaping @Sendable ( C . Element) async throws -> Void
246
252
) -> Self where C: Collection & Sendable , C. Element: Sendable {
247
- let containingTypeInfo = containingType. map ( TypeInfo . init ( describing: ) )
253
+ let containingTypeInfo : TypeInfo ? = if let containingType {
254
+ TypeInfo ( describing: containingType)
255
+ } else {
256
+ nil
257
+ }
248
258
let parameters = paramTuples. parameters
249
259
let caseGenerator = { @Sendable in Case . Generator ( arguments: try await collection ( ) , parameters: parameters, testFunction: testFunction) }
250
260
return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: parameters)
@@ -366,7 +376,7 @@ extension Test {
366
376
/// call it directly.
367
377
public static func __function< C1, C2> (
368
378
named testFunctionName: String ,
369
- in containingType: Any . Type ? ,
379
+ in containingType: ( any ~ Copyable . Type) ? ,
370
380
xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
371
381
displayName: String ? = nil ,
372
382
traits: [ any TestTrait ] ,
@@ -375,7 +385,11 @@ extension Test {
375
385
parameters paramTuples: [ __Parameter ] ,
376
386
testFunction: @escaping @Sendable ( C1 . Element, C2 . Element) async throws -> Void
377
387
) -> Self where C1: Collection & Sendable , C1. Element: Sendable , C2: Collection & Sendable , C2. Element: Sendable {
378
- let containingTypeInfo = containingType. map ( TypeInfo . init ( describing: ) )
388
+ let containingTypeInfo : TypeInfo ? = if let containingType {
389
+ TypeInfo ( describing: containingType)
390
+ } else {
391
+ nil
392
+ }
379
393
let parameters = paramTuples. parameters
380
394
let caseGenerator = { @Sendable in try await Case . Generator ( arguments: collection1 ( ) , collection2 ( ) , parameters: parameters, testFunction: testFunction) }
381
395
return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: parameters)
@@ -390,7 +404,7 @@ extension Test {
390
404
/// call it directly.
391
405
public static func __function< C, E1, E2> (
392
406
named testFunctionName: String ,
393
- in containingType: Any . Type ? ,
407
+ in containingType: ( any ~ Copyable . Type) ? ,
394
408
xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
395
409
displayName: String ? = nil ,
396
410
traits: [ any TestTrait ] ,
@@ -399,7 +413,11 @@ extension Test {
399
413
parameters paramTuples: [ __Parameter ] ,
400
414
testFunction: @escaping @Sendable ( ( E1, E2) ) async throws -> Void
401
415
) -> Self where C: Collection & Sendable , C. Element == ( E1 , E2 ) , E1: Sendable , E2: Sendable {
402
- let containingTypeInfo = containingType. map ( TypeInfo . init ( describing: ) )
416
+ let containingTypeInfo : TypeInfo ? = if let containingType {
417
+ TypeInfo ( describing: containingType)
418
+ } else {
419
+ nil
420
+ }
403
421
let parameters = paramTuples. parameters
404
422
let caseGenerator = { @Sendable in Case . Generator ( arguments: try await collection ( ) , parameters: parameters, testFunction: testFunction) }
405
423
return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: parameters)
@@ -417,7 +435,7 @@ extension Test {
417
435
/// call it directly.
418
436
public static func __function< Key, Value> (
419
437
named testFunctionName: String ,
420
- in containingType: Any . Type ? ,
438
+ in containingType: ( any ~ Copyable . Type) ? ,
421
439
xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
422
440
displayName: String ? = nil ,
423
441
traits: [ any TestTrait ] ,
@@ -426,7 +444,11 @@ extension Test {
426
444
parameters paramTuples: [ __Parameter ] ,
427
445
testFunction: @escaping @Sendable ( ( Key, Value) ) async throws -> Void
428
446
) -> Self where Key: Sendable , Value: Sendable {
429
- let containingTypeInfo = containingType. map ( TypeInfo . init ( describing: ) )
447
+ let containingTypeInfo : TypeInfo ? = if let containingType {
448
+ TypeInfo ( describing: containingType)
449
+ } else {
450
+ nil
451
+ }
430
452
let parameters = paramTuples. parameters
431
453
let caseGenerator = { @Sendable in Case . Generator ( arguments: try await dictionary ( ) , parameters: parameters, testFunction: testFunction) }
432
454
return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: parameters)
@@ -438,7 +460,7 @@ extension Test {
438
460
/// call it directly.
439
461
public static func __function< C1, C2> (
440
462
named testFunctionName: String ,
441
- in containingType: Any . Type ? ,
463
+ in containingType: ( any ~ Copyable . Type) ? ,
442
464
xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
443
465
displayName: String ? = nil ,
444
466
traits: [ any TestTrait ] ,
@@ -447,7 +469,11 @@ extension Test {
447
469
parameters paramTuples: [ __Parameter ] ,
448
470
testFunction: @escaping @Sendable ( C1 . Element, C2 . Element) async throws -> Void
449
471
) -> Self where C1: Collection & Sendable , C1. Element: Sendable , C2: Collection & Sendable , C2. Element: Sendable {
450
- let containingTypeInfo = containingType. map ( TypeInfo . init ( describing: ) )
472
+ let containingTypeInfo : TypeInfo ? = if let containingType {
473
+ TypeInfo ( describing: containingType)
474
+ } else {
475
+ nil
476
+ }
451
477
let parameters = paramTuples. parameters
452
478
let caseGenerator = { @Sendable in
453
479
Case . Generator ( arguments: try await zippedCollections ( ) , parameters: parameters) {
@@ -460,22 +486,22 @@ extension Test {
460
486
461
487
// MARK: - Helper functions
462
488
463
- /// A value that abstracts away whether or not the `try` keyword is needed on an
464
- /// expression.
489
+ /// A function that abstracts away whether or not the `try` keyword is needed on
490
+ /// an expression.
465
491
///
466
- /// - Warning: This value is used to implement the `@Test` macro. Do not use
492
+ /// - Warning: This function is used to implement the `@Test` macro. Do not use
467
493
/// it directly.
468
- @inlinable public var __requiringTry : Void {
469
- @ inlinable get throws { }
494
+ @inlinable public func __requiringTry< T > ( _ value : consuming T ) throws -> T where T : ~ Copyable {
495
+ value
470
496
}
471
497
472
- /// A value that abstracts away whether or not the `await` keyword is needed on
473
- /// an expression.
498
+ /// A function that abstracts away whether or not the `await` keyword is needed
499
+ /// on an expression.
474
500
///
475
- /// - Warning: This value is used to implement the `@Test` macro. Do not use
501
+ /// - Warning: This function is used to implement the `@Test` macro. Do not use
476
502
/// it directly.
477
- @inlinable public var __requiringAwait : Void {
478
- @ inlinable get async { }
503
+ @inlinable public func __requiringAwait< T > ( _ value : consuming T , isolation : isolated ( any Actor ) ? = #isolation ) async -> T where T : ~ Copyable {
504
+ value
479
505
}
480
506
481
507
#if !SWT_NO_GLOBAL_ACTORS
0 commit comments