Skip to content

Commit cc92c30

Browse files
committed
Mark SyntaxChildrenIndex as Sendable
Otherwise consumers of SwiftSyntax may encounter warnings when compiling with `-strict-concurrency=complete`. For example: ```swift extension DeclModifierListSyntax { var fileprivateModifierIndex: DeclModifierListSyntax.Index? { firstIndex(where: { $0.name.tokenKind == .keyword(.fileprivate) }) } var fileprivateModifier: DeclModifierSyntax? { fileprivateModifierIndex.flatMap { self[$0] } } func replacing(fileprivateModifierIndex: DeclModifierListSyntax.Index) -> DeclModifierListSyntax { let fileprivateModifier = self[fileprivateModifierIndex] return with( \.[fileprivateModifierIndex], fileprivateModifier.with( \.name, .keyword( .private, leadingTrivia: fileprivateModifier.leadingTrivia, trailingTrivia: fileprivateModifier.trailingTrivia ) ) ) } } ``` Produces the following warning: > cannot form key path that captures non-sendable type > 'DeclModifierListSyntax.Index' (aka 'SyntaxChildrenIndex')
1 parent d6b6631 commit cc92c30

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Sources/SwiftSyntax/SyntaxChildren.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
/// The data for an index in a syntax children collection that is not the end
1616
/// index. See ``SyntaxChildrenIndex`` for the representation of the end index.
17-
struct SyntaxChildrenIndexData: Hashable, Comparable {
17+
struct SyntaxChildrenIndexData: Hashable, Comparable, Sendable {
1818
/// The UTF-8 offset of the item at this index in the source file
1919
/// See `AbsoluteSyntaxPosition.offset`
2020
let offset: UInt32
@@ -50,7 +50,7 @@ struct SyntaxChildrenIndexData: Hashable, Comparable {
5050
}
5151

5252
/// An index in a syntax children collection.
53-
public struct SyntaxChildrenIndex: Hashable, Comparable, ExpressibleByNilLiteral {
53+
public struct SyntaxChildrenIndex: Hashable, Comparable, ExpressibleByNilLiteral, Sendable {
5454
/// Construct the `endIndex` of a ``SyntaxChildren`` collection.
5555
public init(nilLiteral: ()) {
5656
self.data = nil

Sources/SwiftSyntax/SyntaxIdentifier.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/// Represents a unique value for a node within its own tree.
1414
@_spi(RawSyntax)
15-
public struct SyntaxIndexInTree: Comparable, Hashable {
15+
public struct SyntaxIndexInTree: Comparable, Hashable, Sendable {
1616
let indexInTree: UInt32
1717

1818
static var zero: SyntaxIndexInTree = SyntaxIndexInTree(indexInTree: 0)

0 commit comments

Comments
 (0)