@@ -454,57 +454,53 @@ extension ExitTestConditionMacro {
454
454
"""
455
455
)
456
456
457
- // Create the accessor function for the test content record.
458
- let accessorDecl : DeclSyntax = """
459
- private nonisolated static let accessor: Testing.__TestContentRecordAccessor = { outValue, type, hint in
460
- Testing.ExitTest.__store(
461
- \( exitTestIDExpr) ,
462
- \( bodyThunkName) ,
463
- into: outValue,
464
- asTypeAt: type,
465
- withHintAt: hint
466
- )
467
- }
468
- """
469
-
470
457
// Create a local type that can be discovered at runtime and which contains
471
458
// the exit test body.
472
- let className = context. makeUniqueName ( " __🟡$ " )
473
- let testContentRecordDecl = makeTestContentRecordDecl (
474
- named: . identifier( " testContentRecord " ) ,
475
- in: TypeSyntax ( IdentifierTypeSyntax ( name: className) ) ,
476
- ofKind: . exitTest,
477
- accessingWith: . identifier( " accessor " )
478
- )
459
+ let enumName = context. makeUniqueName ( " " )
460
+ do {
461
+ // Create the test content record.
462
+ let testContentRecordDecl = makeTestContentRecordDecl (
463
+ named: . identifier( " testContentRecord " ) ,
464
+ in: TypeSyntax ( IdentifierTypeSyntax ( name: enumName) ) ,
465
+ ofKind: . exitTest,
466
+ accessingWith: . identifier( " accessor " )
467
+ )
479
468
469
+ // Create another local type for legacy test discovery.
470
+ var recordDecl : DeclSyntax ?
480
471
#if !SWT_NO_LEGACY_TEST_DISCOVERY
481
- decls. append (
482
- """
483
- @available(*, deprecated, message: " This type is an implementation detail of the testing library. Do not use it directly. " )
484
- final class \( className) : Testing.__TestContentRecordContainer {
485
- \( accessorDecl)
486
-
487
- \( testContentRecordDecl)
488
-
472
+ let className = context. makeUniqueName ( " __🟡$ " )
473
+ recordDecl = """
474
+ private final class \( className) : Testing.__TestContentRecordContainer {
489
475
override nonisolated class var __testContentRecord: Testing.__TestContentRecord {
490
- testContentRecord
476
+ \( enumName ) . testContentRecord
491
477
}
492
478
}
493
479
"""
494
- )
495
- #else
496
- decls. append (
497
- """
498
- @available(*, deprecated, message: " This type is an implementation detail of the testing library. Do not use it directly. " )
499
- final class \( className) {
500
- \( accessorDecl)
501
-
502
- \( testContentRecordDecl)
503
- }
504
- """
505
- )
506
480
#endif
507
481
482
+ decls. append (
483
+ """
484
+ @available(*, deprecated, message: " This type is an implementation detail of the testing library. Do not use it directly. " )
485
+ enum \( enumName) {
486
+ private nonisolated static let accessor: Testing.__TestContentRecordAccessor = { outValue, type, hint in
487
+ Testing.ExitTest.__store(
488
+ \( exitTestIDExpr) ,
489
+ \( bodyThunkName) ,
490
+ into: outValue,
491
+ asTypeAt: type,
492
+ withHintAt: hint
493
+ )
494
+ }
495
+
496
+ \( testContentRecordDecl)
497
+
498
+ \( recordDecl)
499
+ }
500
+ """
501
+ )
502
+ }
503
+
508
504
arguments [ trailingClosureIndex] . expression = ExprSyntax (
509
505
ClosureExprSyntax {
510
506
for decl in decls {
0 commit comments