Skip to content

Commit 1f0e7d5

Browse files
committed
Mark Syntax.Info as @unchecked Sendable
We were relying on the `nonisolated(unsafe)` annotation of `Info.info` to make `Sendable` checking pass. But that feature is only available in Swift 6.0. To be able to build swift-syntax without warnings using Swift <6.0, we need to use `@unchecked Sendable` here.
1 parent 8d5614e commit 1f0e7d5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Sources/SwiftSyntax/Syntax.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
public struct Syntax: SyntaxProtocol, SyntaxHashable {
1717
/// We need a heap indirection to store a syntax node's parent. We could use an indirect enum here but explicitly
1818
/// modelling it using a class allows us to re-use these heap-allocated objects in `SyntaxVisitor`.
19-
final class Info: Sendable {
19+
///
20+
/// - Note: `@unchecked Sendable` because `info` is mutable. In Swift 6 and above the variable can be declared as
21+
/// `nonisolated(unsafe)` but that attribute doesn't exist in previous Swift versions and a checked Sendable
22+
/// conformance generates a warning.
23+
final class Info: @unchecked Sendable {
2024
// For root node.
2125
struct Root: Sendable {
2226
private var arena: RetainedSyntaxArena

0 commit comments

Comments
 (0)