Skip to content

Commit 33622d7

Browse files
authored
Work around SwiftSyntax-related warning in CI. (#183)
We are getting a new warning in CI: ``` .../swift-testing/Sources/TestingMacros/ConditionMacro.swift:46:13: warning: let '_sourceLocationLabel' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor; this is an error in Swift 6 private let _sourceLocationLabel = TokenSyntax.identifier("sourceLocation") ^ ``` Work around it by using `private var ... {}` instead of `private let`. I'm assuming that creating a `TokenSyntax` is not prohibitively expensive, so the change should be safe. @ahoppen confirms that this operation is reasonably cheap and that syntax nodes are not safely sendable in the 5.9 tag of swift-syntax, so the warning is technically valid. Although our code does not access these constants across concurrency domains, the compiler is (in theory) free to invoke our macro expansion code on multiple tasks concurrently. Concurrency safety in swift-syntax is tracked with swiftlang/swift-syntax#2425.
1 parent 61227db commit 33622d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/TestingMacros/ConditionMacro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ private protocol _ConditionMacro: ExpressionMacro, Sendable {
4343

4444
/// The token used as the label of the source location argument passed to
4545
/// `#expect()` and `#require()`.
46-
private let _sourceLocationLabel = TokenSyntax.identifier("sourceLocation")
46+
private var _sourceLocationLabel: TokenSyntax { .identifier("sourceLocation") }
4747

4848
/// The token used as a mandatory label on any (first) trailing closure used
4949
/// with `#expect()` or `#require()`.
50-
private let _trailingClosureLabel = TokenSyntax.identifier("performing")
50+
private var _trailingClosureLabel: TokenSyntax { .identifier("performing") }
5151

5252
extension _ConditionMacro {
5353
public static func expansion(

0 commit comments

Comments
 (0)