Skip to content

Commit 7b750bf

Browse files
committed
Make swift-syntax build in Swift 6 language mode
1 parent 462e954 commit 7b750bf

File tree

13 files changed

+24
-17
lines changed

13 files changed

+24
-17
lines changed

Package.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ let package = Package(
297297
dependencies: ["_InstructionCounter", "_SwiftSyntaxTestSupport", "SwiftIDEUtils", "SwiftParser", "SwiftSyntax"],
298298
exclude: ["Inputs"]
299299
),
300-
]
300+
],
301+
swiftLanguageVersions: [.v5, .version("6")]
301302
)
302303

303304
// This is a fake target that depends on all targets in the package.

Sources/SwiftParser/ExpressionInterpretedAsVersionTuple.swift

+4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#if swift(>=6)
14+
@_spi(RawSyntax) public import SwiftSyntax
15+
#else
1316
@_spi(RawSyntax) import SwiftSyntax
17+
#endif
1418

1519
extension ExprSyntax {
1620
/// Parse the source code of this node as a `VersionTupleSyntax`.

Sources/SwiftParser/TokenSpec.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct PrepareForKeywordMatch {
4949
/// matching against and is thus able to rule out one of the branches in
5050
/// `matches(rawTokenKind:text:)` based on the matched kind.
5151
@_spi(AlternateTokenIntrospection)
52-
public struct TokenSpec {
52+
public struct TokenSpec: Sendable {
5353
/// The kind we expect the token that we want to consume to have.
5454
/// This can be a keyword, in which case the ``TokenSpec`` will also match an
5555
/// identifier with the same text as the keyword and remap it to that keyword

Sources/SwiftParser/TokenSpecSet.swift

-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#if swift(>=6)
14-
@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) public import SwiftSyntax
15-
#else
1613
@_spi(RawSyntax) @_spi(ExperimentalLanguageFeatures) import SwiftSyntax
17-
#endif
1814

1915
/// A set of `TokenSpecs`. We expect to consume one of the sets specs in the
2016
/// parser.

Sources/SwiftSyntaxMacrosTestSupport/Assertions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public struct NoteSpec {
6363
message: String,
6464
line: Int,
6565
column: Int,
66-
originatorFile: StaticString = #file,
66+
originatorFile: StaticString = #filePath,
6767
originatorLine: UInt = #line
6868
) {
6969
self.message = message

SwiftSyntaxDevUtils/Sources/swift-syntax-dev-utils/common/Paths.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Foundation
1414

1515
enum Paths {
1616
static var packageDir: URL {
17-
URL(fileURLWithPath: #file)
17+
URL(fileURLWithPath: #filePath)
1818
.deletingLastPathComponent()
1919
.deletingLastPathComponent()
2020
.deletingLastPathComponent()

Tests/PerformanceTest/InstructionsCountAssertion.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fileprivate var baselineURL: URL {
1717
if let baselineFile = ProcessInfo.processInfo.environment["BASELINE_FILE"] {
1818
return URL(fileURLWithPath: baselineFile)
1919
} else {
20-
return URL(fileURLWithPath: #file)
20+
return URL(fileURLWithPath: #filePath)
2121
.deletingLastPathComponent()
2222
.appendingPathComponent("baselines.json")
2323
}

Tests/PerformanceTest/ParsingPerformanceTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import _SwiftSyntaxTestSupport
1818
class ParsingPerformanceTests: XCTestCase {
1919

2020
var inputFile: URL {
21-
return URL(fileURLWithPath: #file)
21+
return URL(fileURLWithPath: #filePath)
2222
.deletingLastPathComponent()
2323
.appendingPathComponent("Inputs")
2424
.appendingPathComponent("MinimalCollections.swift.input")

Tests/PerformanceTest/SyntaxClassifierPerformanceTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import _SwiftSyntaxTestSupport
1919
class SyntaxClassifierPerformanceTests: XCTestCase {
2020

2121
var inputFile: URL {
22-
return URL(fileURLWithPath: #file)
22+
return URL(fileURLWithPath: #filePath)
2323
.deletingLastPathComponent()
2424
.appendingPathComponent("Inputs")
2525
.appendingPathComponent("MinimalCollections.swift.input")

Tests/PerformanceTest/VisitorPerformanceTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import _SwiftSyntaxTestSupport
1818
class VisitorPerformanceTests: XCTestCase {
1919

2020
var inputFile: URL {
21-
return URL(fileURLWithPath: #file)
21+
return URL(fileURLWithPath: #filePath)
2222
.deletingLastPathComponent()
2323
.appendingPathComponent("Inputs")
2424
.appendingPathComponent("MinimalCollections.swift.input")

Tests/SwiftParserTest/ParserTests.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,20 @@ class ParserTests: ParserTestCase {
6161
checkDiagnostics: Bool,
6262
shouldExclude: @Sendable (URL) -> Bool = { _ in false }
6363
) {
64-
let fileURLs = FileManager.default
64+
// nonisolated(unsafe) because [URL] is not marked Sendable on Linux.
65+
let _fileURLs = FileManager.default
6566
.enumerator(at: path, includingPropertiesForKeys: nil)!
6667
.compactMap({ $0 as? URL })
6768
.filter {
6869
$0.pathExtension == "swift"
6970
|| $0.pathExtension == "sil"
7071
|| $0.pathExtension == "swiftinterface"
7172
}
73+
#if swift(>=6.0)
74+
nonisolated(unsafe) let fileURLs = _fileURLs
75+
#else
76+
let fileURLs = _fileURLs
77+
#endif
7278

7379
print("\(name) - processing \(fileURLs.count) source files")
7480
DispatchQueue.concurrentPerform(iterations: fileURLs.count) { fileURLIndex in
@@ -85,7 +91,7 @@ class ParserTests: ParserTestCase {
8591
}
8692
}
8793

88-
let packageDir = URL(fileURLWithPath: #file)
94+
let packageDir = URL(fileURLWithPath: #filePath)
8995
.deletingLastPathComponent()
9096
.deletingLastPathComponent()
9197
.deletingLastPathComponent()

Tests/SwiftParserTest/SequentialToConcurrentEditTranslationTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func verifySequentialToConcurrentTranslation(
3737
_ sequential: [IncrementalEdit],
3838
_ expectedConcurrent: [IncrementalEdit],
3939
testString: String = longString,
40-
file: StaticString = #file,
40+
file: StaticString = #filePath,
4141
line: UInt = #line
4242
) {
4343
let concurrent = ConcurrentEdits(fromSequential: sequential)

Tests/SwiftSyntaxMacroExpansionTest/LexicalContextTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ struct AllLexicalContextsMacro: DeclarationMacro {
200200
}
201201
}
202202

203-
public struct LexicalContextDescriptionMacro: ExpressionMacro {
204-
public static func expansion(
203+
struct LexicalContextDescriptionMacro: ExpressionMacro {
204+
static func expansion(
205205
of node: some FreestandingMacroExpansionSyntax,
206206
in context: some MacroExpansionContext
207207
) throws -> ExprSyntax {

0 commit comments

Comments
 (0)