Skip to content

Commit f8ef65d

Browse files
committed
Build SourceKit-LSP in the Swift 6 language mode
rdar://126553799
1 parent 65c1816 commit f8ef65d

26 files changed

+260
-172
lines changed

Package.swift

Lines changed: 27 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
import Foundation
44
import PackageDescription
55

6-
let strictConcurrencySettings: [SwiftSetting] = [
7-
.enableUpcomingFeature("StrictConcurrency"),
8-
.enableUpcomingFeature("RegionBasedIsolation"),
9-
.enableUpcomingFeature("InferSendableFromCaptures"),
10-
]
11-
126
let package = Package(
137
name: "SourceKitLSP",
148
platforms: [.macOS(.v13)],
@@ -40,7 +34,6 @@ let package = Package(
4034
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
4135
],
4236
exclude: ["CMakeLists.txt"],
43-
swiftSettings: strictConcurrencySettings,
4437
linkerSettings: sourcekitLSPLinkSettings
4538
),
4639

@@ -52,8 +45,7 @@ let package = Package(
5245
dependencies: [
5346
"LanguageServerProtocol"
5447
],
55-
exclude: ["CMakeLists.txt"],
56-
swiftSettings: strictConcurrencySettings
48+
exclude: ["CMakeLists.txt"]
5749
),
5850

5951
// MARK: CAtomics
@@ -94,8 +86,7 @@ let package = Package(
9486
.product(name: "SwiftParser", package: "swift-syntax"),
9587
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
9688
],
97-
exclude: ["CMakeLists.txt"],
98-
swiftSettings: strictConcurrencySettings
89+
exclude: ["CMakeLists.txt"]
9990
),
10091

10192
.testTarget(
@@ -108,8 +99,7 @@ let package = Package(
10899
"SKCore",
109100
"SKTestSupport",
110101
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
111-
],
112-
swiftSettings: strictConcurrencySettings
102+
]
113103
),
114104

115105
// MARK: InProcessClient
@@ -122,26 +112,23 @@ let package = Package(
122112
"SKCore",
123113
"SourceKitLSP",
124114
],
125-
exclude: ["CMakeLists.txt"],
126-
swiftSettings: strictConcurrencySettings
115+
exclude: ["CMakeLists.txt"]
127116
),
128117

129118
// MARK: LanguageServerProtocol
130119
// The core LSP types, suitable for any LSP implementation.
131120
.target(
132121
name: "LanguageServerProtocol",
133122
dependencies: [],
134-
exclude: ["CMakeLists.txt"],
135-
swiftSettings: strictConcurrencySettings
123+
exclude: ["CMakeLists.txt"]
136124
),
137125

138126
.testTarget(
139127
name: "LanguageServerProtocolTests",
140128
dependencies: [
141129
"LanguageServerProtocol",
142130
"LSPTestSupport",
143-
],
144-
swiftSettings: strictConcurrencySettings
131+
]
145132
),
146133

147134
// MARK: LanguageServerProtocolJSONRPC
@@ -153,17 +140,15 @@ let package = Package(
153140
"LanguageServerProtocol",
154141
"LSPLogging",
155142
],
156-
exclude: ["CMakeLists.txt"],
157-
swiftSettings: strictConcurrencySettings
143+
exclude: ["CMakeLists.txt"]
158144
),
159145

160146
.testTarget(
161147
name: "LanguageServerProtocolJSONRPCTests",
162148
dependencies: [
163149
"LanguageServerProtocolJSONRPC",
164150
"LSPTestSupport",
165-
],
166-
swiftSettings: strictConcurrencySettings
151+
]
167152
),
168153

169154
// MARK: LSPLogging
@@ -176,16 +161,15 @@ let package = Package(
176161
.product(name: "Crypto", package: "swift-crypto"),
177162
],
178163
exclude: ["CMakeLists.txt"],
179-
swiftSettings: lspLoggingSwiftSettings + strictConcurrencySettings
164+
swiftSettings: lspLoggingSwiftSettings
180165
),
181166

182167
.testTarget(
183168
name: "LSPLoggingTests",
184169
dependencies: [
185170
"LSPLogging",
186171
"SKTestSupport",
187-
],
188-
swiftSettings: strictConcurrencySettings
172+
]
189173
),
190174

191175
// MARK: LSPTestSupport
@@ -198,8 +182,7 @@ let package = Package(
198182
"LanguageServerProtocolJSONRPC",
199183
"SKSupport",
200184
"SwiftExtensions",
201-
],
202-
swiftSettings: strictConcurrencySettings
185+
]
203186
),
204187

205188
// MARK: SemanticIndex
@@ -213,8 +196,7 @@ let package = Package(
213196
"SwiftExtensions",
214197
.product(name: "IndexStoreDB", package: "indexstore-db"),
215198
],
216-
exclude: ["CMakeLists.txt"],
217-
swiftSettings: strictConcurrencySettings
199+
exclude: ["CMakeLists.txt"]
218200
),
219201

220202
.testTarget(
@@ -223,8 +205,7 @@ let package = Package(
223205
"LSPLogging",
224206
"SemanticIndex",
225207
"SKTestSupport",
226-
],
227-
swiftSettings: strictConcurrencySettings
208+
]
228209
),
229210

230211
// MARK: SKCore
@@ -244,17 +225,15 @@ let package = Package(
244225
.product(name: "SwiftPMDataModel-auto", package: "swift-package-manager"),
245226
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
246227
],
247-
exclude: ["CMakeLists.txt"],
248-
swiftSettings: strictConcurrencySettings
228+
exclude: ["CMakeLists.txt"]
249229
),
250230

251231
.testTarget(
252232
name: "SKCoreTests",
253233
dependencies: [
254234
"SKCore",
255235
"SKTestSupport",
256-
],
257-
swiftSettings: strictConcurrencySettings
236+
]
258237
),
259238

260239
// MARK: SKSupport
@@ -270,8 +249,7 @@ let package = Package(
270249
"SwiftExtensions",
271250
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
272251
],
273-
exclude: ["CMakeLists.txt"],
274-
swiftSettings: strictConcurrencySettings
252+
exclude: ["CMakeLists.txt"]
275253
),
276254

277255
.testTarget(
@@ -281,8 +259,7 @@ let package = Package(
281259
"SKSupport",
282260
"SKTestSupport",
283261
"SwiftExtensions",
284-
],
285-
swiftSettings: strictConcurrencySettings
262+
]
286263
),
287264

288265
// MARK: SKSwiftPMWorkspace
@@ -298,8 +275,7 @@ let package = Package(
298275
.product(name: "SwiftPM-auto", package: "swift-package-manager"),
299276
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
300277
],
301-
exclude: ["CMakeLists.txt"],
302-
swiftSettings: strictConcurrencySettings
278+
exclude: ["CMakeLists.txt"]
303279
),
304280

305281
.testTarget(
@@ -313,8 +289,7 @@ let package = Package(
313289
"SourceKitLSP",
314290
.product(name: "SwiftPM-auto", package: "swift-package-manager"),
315291
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
316-
],
317-
swiftSettings: strictConcurrencySettings
292+
]
318293
),
319294

320295
// MARK: SKTestSupport
@@ -333,8 +308,7 @@ let package = Package(
333308
.product(name: "ISDBTestSupport", package: "indexstore-db"),
334309
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
335310
],
336-
resources: [.copy("INPUTS")],
337-
swiftSettings: strictConcurrencySettings
311+
resources: [.copy("INPUTS")]
338312
),
339313

340314
// MARK: SourceKitD
@@ -348,8 +322,7 @@ let package = Package(
348322
"SwiftExtensions",
349323
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
350324
],
351-
exclude: ["CMakeLists.txt", "sourcekitd_uids.swift.gyb"],
352-
swiftSettings: strictConcurrencySettings
325+
exclude: ["CMakeLists.txt", "sourcekitd_uids.swift.gyb"]
353326
),
354327

355328
.testTarget(
@@ -359,8 +332,7 @@ let package = Package(
359332
"SKCore",
360333
"SKTestSupport",
361334
"SwiftExtensions",
362-
],
363-
swiftSettings: strictConcurrencySettings
335+
]
364336
),
365337

366338
// MARK: SourceKitLSP
@@ -390,8 +362,7 @@ let package = Package(
390362
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
391363
.product(name: "SwiftPM-auto", package: "swift-package-manager"),
392364
],
393-
exclude: ["CMakeLists.txt"],
394-
swiftSettings: strictConcurrencySettings
365+
exclude: ["CMakeLists.txt"]
395366
),
396367

397368
.testTarget(
@@ -416,18 +387,17 @@ let package = Package(
416387
// be used by test cases that test macros (see `SwiftPMTestProject.macroPackageManifest`).
417388
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
418389
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
419-
],
420-
swiftSettings: strictConcurrencySettings
390+
]
421391
),
422392

423393
// MARK: SwiftExtensions
424394

425395
.target(
426396
name: "SwiftExtensions",
427-
exclude: ["CMakeLists.txt"],
428-
swiftSettings: strictConcurrencySettings
397+
exclude: ["CMakeLists.txt"]
429398
),
430-
]
399+
],
400+
swiftLanguageVersions: [.v5, .version("6")]
431401
)
432402

433403
// MARK: - Parse build arguments

Sources/Diagnose/IndexCommand.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,4 @@ fileprivate extension SourceKitLSPServer {
120120
}
121121
}
122122

123-
#if compiler(>=6)
124-
extension ExperimentalFeature: @retroactive ExpressibleByArgument {}
125-
#else
126123
extension ExperimentalFeature: ExpressibleByArgument {}
127-
#endif

Sources/Diagnose/StderrStreamConcurrencySafe.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import TSCLibc
14-
1513
import class TSCBasic.LocalFileOutputByteStream
1614
import class TSCBasic.ThreadSafeOutputByteStream
1715

16+
#if canImport(Darwin)
17+
import TSCLibc
18+
#else
19+
// FIXME: (async-workaround) @preconcurrency needed because stderr is not sendable on Linux rdar://125578486
20+
@preconcurrency import TSCLibc
21+
#endif
22+
1823
// A version of `stderrStream` from `TSCBasic` that is a `let` and can thus be used from Swift 6.
1924
let stderrStreamConcurrencySafe: ThreadSafeOutputByteStream = try! ThreadSafeOutputByteStream(
2025
LocalFileOutputByteStream(

Sources/LSPLogging/NonDarwinLogging.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import Foundation
1413
import SwiftExtensions
1514

15+
#if canImport(Darwin)
16+
import Foundation
17+
#else
18+
// FIMXE: (async-workaround) @preconcurrency needed because DateFormatter and stderr are not marked as Sendable on Linux
19+
// rdar://125578486, rdar://132378589
20+
@preconcurrency import Foundation
21+
#endif
22+
1623
// MARK: - Log settings
1724

1825
package enum LogConfig {

Sources/LSPLogging/SetGlobalLogFileHandler.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import Foundation
1413
import RegexBuilder
1514

15+
#if canImport(Darwin)
16+
import Foundation
17+
#else
18+
// FIMXE: (async-workaround) @preconcurrency needed because DateFormatter and stderr are not marked as Sendable on Linux
19+
// rdar://125578486, rdar://132378589
20+
@preconcurrency import Foundation
21+
#endif
22+
1623
#if os(Windows)
1724
import WinSDK
1825
#endif

Sources/LSPTestSupport/Assertions.swift

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -112,36 +112,34 @@ package func unwrap<T>(
112112
return try XCTUnwrap(expression, file: file, line: line)
113113
}
114114

115-
extension XCTestCase {
116-
private struct ExpectationNotFulfilledError: Error, CustomStringConvertible {
117-
var expecatations: [XCTestExpectation]
115+
private struct ExpectationNotFulfilledError: Error, CustomStringConvertible {
116+
var expecatations: [XCTestExpectation]
118117

119-
var description: String {
120-
return """
121-
One of the expectation was not fulfilled within timeout: \
122-
\(expecatations.map(\.description).joined(separator: ", "))
123-
"""
124-
}
118+
var description: String {
119+
return """
120+
One of the expectation was not fulfilled within timeout: \
121+
\(expecatations.map(\.description).joined(separator: ", "))
122+
"""
125123
}
124+
}
126125

127-
/// Wait for the given expectations to be fulfilled. If the expectations aren't
128-
/// fulfilled within `timeout`, throw an error, aborting the test execution.
129-
package func fulfillmentOfOrThrow(
130-
_ expectations: [XCTestExpectation],
131-
timeout: TimeInterval = defaultTimeout,
132-
enforceOrder enforceOrderOfFulfillment: Bool = false
133-
) async throws {
134-
// `XCTWaiter.fulfillment` was introduced in the macOS 13.3 SDK but marked as being available on macOS 10.15.
135-
// At the same time that XCTWaiter.fulfillment was introduced `XCTWaiter.wait` was deprecated in async contexts.
136-
// This means that we can't write code that compiles without warnings with both the macOS 13.3 and any previous SDK.
137-
// Accepting the warning here when compiling with macOS 13.3 or later is the only thing that I know of that we can do here.
138-
let started = await XCTWaiter.fulfillment(
139-
of: expectations,
140-
timeout: timeout,
141-
enforceOrder: enforceOrderOfFulfillment
142-
)
143-
if started != .completed {
144-
throw ExpectationNotFulfilledError(expecatations: expectations)
145-
}
126+
/// Wait for the given expectations to be fulfilled. If the expectations aren't
127+
/// fulfilled within `timeout`, throw an error, aborting the test execution.
128+
package nonisolated func fulfillmentOfOrThrow(
129+
_ expectations: [XCTestExpectation],
130+
timeout: TimeInterval = defaultTimeout,
131+
enforceOrder enforceOrderOfFulfillment: Bool = false
132+
) async throws {
133+
// `XCTWaiter.fulfillment` was introduced in the macOS 13.3 SDK but marked as being available on macOS 10.15.
134+
// At the same time that XCTWaiter.fulfillment was introduced `XCTWaiter.wait` was deprecated in async contexts.
135+
// This means that we can't write code that compiles without warnings with both the macOS 13.3 and any previous SDK.
136+
// Accepting the warning here when compiling with macOS 13.3 or later is the only thing that I know of that we can do here.
137+
let started = await XCTWaiter.fulfillment(
138+
of: expectations,
139+
timeout: timeout,
140+
enforceOrder: enforceOrderOfFulfillment
141+
)
142+
if started != .completed {
143+
throw ExpectationNotFulfilledError(expecatations: expectations)
146144
}
147145
}

0 commit comments

Comments
 (0)