Skip to content

Commit 9c9d158

Browse files
authored
Merge pull request #2681 from apple/jed/cherry-pick-sendables
[6.0] Mark MacroSpec & SourceLocationConverter as Sendable
2 parents 4c6cc0a + 1263483 commit 9c9d158

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
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.

Sources/SwiftSyntaxMacroExpansion/MacroSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import SwiftSyntaxMacros
2121
/// The information of a macro declaration, to be used with `assertMacroExpansion`.
2222
///
2323
/// In addition to specifying the macro’s type, this allows the specification of conformances that will be passed to the macro’s `expansion` function.
24-
public struct MacroSpec {
24+
public struct MacroSpec: Sendable {
2525
/// The type of macro.
2626
let type: Macro.Type
2727
/// The list of types for which the macro needs to add conformances.

0 commit comments

Comments
 (0)