Skip to content

Commit 0018a42

Browse files
authored
Don't emit @_section attributes unless the macro target has SymbolLinkageMarkers. (#1018)
This PR suppresses our use of `@_section` and `@_used` unless the macro target is built with `SymbolLinkageMarkers` enabled. Resolves rdar://146819169. ### Checklist: - [x] Code and documentation should follow the style of the [Style Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md). - [x] If public symbols are renamed or modified, DocC references should be updated.
1 parent 77fa261 commit 0018a42

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

Sources/TestingMacros/Support/TestContentGeneration.swift

+17-9
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,19 @@ func makeTestContentRecordDecl(named name: TokenSyntax, in typeName: TypeSyntax?
6262
IntegerLiteralExprSyntax(context, radix: .binary)
6363
}
6464

65-
return """
65+
var result: DeclSyntax = """
66+
@available(*, deprecated, message: "This property is an implementation detail of the testing library. Do not use it directly.")
67+
private nonisolated \(staticKeyword(for: typeName)) let \(name): Testing.__TestContentRecord = (
68+
\(kindExpr), \(kind.commentRepresentation)
69+
0,
70+
\(accessorName),
71+
\(contextExpr),
72+
0
73+
)
74+
"""
75+
76+
#if hasFeature(SymbolLinkageMarkers)
77+
result = """
6678
#if hasFeature(SymbolLinkageMarkers)
6779
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)
6880
@_section("__DATA_CONST,__swift5_tests")
@@ -75,13 +87,9 @@ func makeTestContentRecordDecl(named name: TokenSyntax, in typeName: TypeSyntax?
7587
#endif
7688
@_used
7789
#endif
78-
@available(*, deprecated, message: "This property is an implementation detail of the testing library. Do not use it directly.")
79-
private nonisolated \(staticKeyword(for: typeName)) let \(name): Testing.__TestContentRecord = (
80-
\(kindExpr), \(kind.commentRepresentation)
81-
0,
82-
\(accessorName),
83-
\(contextExpr),
84-
0
85-
)
90+
\(result)
8691
"""
92+
#endif
93+
94+
return result
8795
}

0 commit comments

Comments
 (0)