@@ -106,7 +106,7 @@ extension Test {
106106 /// - Warning: This function is used to implement the `@Suite` macro. Do not
107107 /// call it directly.
108108 public static func __type(
109- _ containingType: Any . Type ,
109+ _ containingType: any ~ Copyable . Type,
110110 displayName: String ? = nil ,
111111 traits: [ any SuiteTrait ] ,
112112 sourceLocation: SourceLocation
@@ -159,15 +159,21 @@ extension Test {
159159 /// call it directly.
160160 public static func __function(
161161 named testFunctionName: String ,
162- in containingType: Any . Type ? ,
162+ in containingType: ( any ~ Copyable . Type) ? ,
163163 xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
164164 displayName: String ? = nil ,
165165 traits: [ any TestTrait ] ,
166166 sourceLocation: SourceLocation ,
167167 parameters: [ __Parameter ] = [ ] ,
168168 testFunction: @escaping @Sendable ( ) async throws -> Void
169169 ) -> 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+ }
171177 let caseGenerator = { @Sendable in Case . Generator ( testFunction: testFunction) }
172178 return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: [ ] )
173179 }
@@ -235,7 +241,7 @@ extension Test {
235241 /// call it directly.
236242 public static func __function< C> (
237243 named testFunctionName: String ,
238- in containingType: Any . Type ? ,
244+ in containingType: ( any ~ Copyable . Type) ? ,
239245 xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
240246 displayName: String ? = nil ,
241247 traits: [ any TestTrait ] ,
@@ -244,7 +250,11 @@ extension Test {
244250 parameters paramTuples: [ __Parameter ] ,
245251 testFunction: @escaping @Sendable ( C . Element) async throws -> Void
246252 ) -> 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+ }
248258 let parameters = paramTuples. parameters
249259 let caseGenerator = { @Sendable in Case . Generator ( arguments: try await collection ( ) , parameters: parameters, testFunction: testFunction) }
250260 return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: parameters)
@@ -366,7 +376,7 @@ extension Test {
366376 /// call it directly.
367377 public static func __function< C1, C2> (
368378 named testFunctionName: String ,
369- in containingType: Any . Type ? ,
379+ in containingType: ( any ~ Copyable . Type) ? ,
370380 xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
371381 displayName: String ? = nil ,
372382 traits: [ any TestTrait ] ,
@@ -375,7 +385,11 @@ extension Test {
375385 parameters paramTuples: [ __Parameter ] ,
376386 testFunction: @escaping @Sendable ( C1 . Element, C2 . Element) async throws -> Void
377387 ) -> 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+ }
379393 let parameters = paramTuples. parameters
380394 let caseGenerator = { @Sendable in try await Case . Generator ( arguments: collection1 ( ) , collection2 ( ) , parameters: parameters, testFunction: testFunction) }
381395 return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: parameters)
@@ -390,7 +404,7 @@ extension Test {
390404 /// call it directly.
391405 public static func __function< C, E1, E2> (
392406 named testFunctionName: String ,
393- in containingType: Any . Type ? ,
407+ in containingType: ( any ~ Copyable . Type) ? ,
394408 xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
395409 displayName: String ? = nil ,
396410 traits: [ any TestTrait ] ,
@@ -399,7 +413,11 @@ extension Test {
399413 parameters paramTuples: [ __Parameter ] ,
400414 testFunction: @escaping @Sendable ( ( E1, E2) ) async throws -> Void
401415 ) -> 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+ }
403421 let parameters = paramTuples. parameters
404422 let caseGenerator = { @Sendable in Case . Generator ( arguments: try await collection ( ) , parameters: parameters, testFunction: testFunction) }
405423 return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: parameters)
@@ -417,7 +435,7 @@ extension Test {
417435 /// call it directly.
418436 public static func __function< Key, Value> (
419437 named testFunctionName: String ,
420- in containingType: Any . Type ? ,
438+ in containingType: ( any ~ Copyable . Type) ? ,
421439 xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
422440 displayName: String ? = nil ,
423441 traits: [ any TestTrait ] ,
@@ -426,7 +444,11 @@ extension Test {
426444 parameters paramTuples: [ __Parameter ] ,
427445 testFunction: @escaping @Sendable ( ( Key, Value) ) async throws -> Void
428446 ) -> 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+ }
430452 let parameters = paramTuples. parameters
431453 let caseGenerator = { @Sendable in Case . Generator ( arguments: try await dictionary ( ) , parameters: parameters, testFunction: testFunction) }
432454 return Self ( name: testFunctionName, displayName: displayName, traits: traits, sourceLocation: sourceLocation, containingTypeInfo: containingTypeInfo, xcTestCompatibleSelector: xcTestCompatibleSelector, testCases: caseGenerator, parameters: parameters)
@@ -438,7 +460,7 @@ extension Test {
438460 /// call it directly.
439461 public static func __function< C1, C2> (
440462 named testFunctionName: String ,
441- in containingType: Any . Type ? ,
463+ in containingType: ( any ~ Copyable . Type) ? ,
442464 xcTestCompatibleSelector: __XCTestCompatibleSelector ? ,
443465 displayName: String ? = nil ,
444466 traits: [ any TestTrait ] ,
@@ -447,7 +469,11 @@ extension Test {
447469 parameters paramTuples: [ __Parameter ] ,
448470 testFunction: @escaping @Sendable ( C1 . Element, C2 . Element) async throws -> Void
449471 ) -> 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+ }
451477 let parameters = paramTuples. parameters
452478 let caseGenerator = { @Sendable in
453479 Case . Generator ( arguments: try await zippedCollections ( ) , parameters: parameters) {
@@ -460,22 +486,22 @@ extension Test {
460486
461487// MARK: - Helper functions
462488
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.
465491///
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
467493/// 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
470496}
471497
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.
474500///
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
476502/// 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
479505}
480506
481507#if !SWT_NO_GLOBAL_ACTORS
0 commit comments