Skip to content

Commit 4492754

Browse files
committed
Make SourceLocationConverter Sendable
1 parent 4d300ac commit 4492754

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Sources/SwiftSyntax/SourceLocation.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fileprivate struct SourceLocationDirectiveArguments {
141141
/// Converts ``AbsolutePosition``s of syntax nodes to ``SourceLocation``s, and
142142
/// vice-versa. The ``AbsolutePosition``s must be originating from nodes that are
143143
/// part of the same tree that was used to initialize this class.
144-
public final class SourceLocationConverter {
144+
public final class SourceLocationConverter: Sendable {
145145
private let fileName: String
146146
/// The source of the file, modeled as data so it can contain invalid UTF-8.
147147
private let source: [UInt8]
@@ -157,7 +157,7 @@ public final class SourceLocationConverter {
157157
/// `#sourceLocation(...)` directive within the current file.
158158
/// - `arguments` are the `file` and `line` arguments of the directive or `nil`
159159
/// if spelled as `#sourceLocation()` to reset the source location directive.
160-
private var sourceLocationDirectives: [(sourceLine: Int, arguments: SourceLocationDirectiveArguments?)] = []
160+
private let sourceLocationDirectives: [(sourceLine: Int, arguments: SourceLocationDirectiveArguments?)]
161161

162162
/// Create a new ``SourceLocationConverter`` to convert between ``AbsolutePosition``
163163
/// and ``SourceLocation`` in a syntax tree.
@@ -212,6 +212,7 @@ public final class SourceLocationConverter {
212212
return computeLines(SyntaxText(buffer: syntaxArenaBuf))
213213
}
214214
precondition(source.utf8.count == endOfFile.utf8Offset)
215+
self.sourceLocationDirectives = []
215216
}
216217

217218
/// Execute the body with an array that contains each source line.

0 commit comments

Comments
 (0)