Skip to content

Commit 2f14afb

Browse files
authored
Merge pull request #1276 from ahoppen/non-test-modules-in-swift-6-mode
Make all non-test modules except for SourceKitLSP build in Swift 6 mode
2 parents 4bff560 + 70e373c commit 2f14afb

File tree

8 files changed

+19
-45
lines changed

8 files changed

+19
-45
lines changed

Sources/SKCore/FallbackBuildSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Foundation
1616
import LanguageServerProtocol
1717
import SKSupport
1818

19-
@preconcurrency import enum PackageLoading.Platform
19+
import enum PackageLoading.Platform
2020
import struct TSCBasic.AbsolutePath
2121
import class TSCBasic.Process
2222

Sources/SKCore/Toolchain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import LSPLogging
1414
import LanguageServerProtocol
1515
import SKSupport
1616

17-
@preconcurrency import enum PackageLoading.Platform
17+
import enum PackageLoading.Platform
1818
import struct TSCBasic.AbsolutePath
1919
import protocol TSCBasic.FileSystem
2020
import var TSCBasic.localFileSystem

Sources/SKSupport/Process+LaunchWithWorkingDirectoryIfPossible.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ extension Process {
2626
arguments: [String],
2727
environmentBlock: ProcessEnvironmentBlock = ProcessEnv.block,
2828
workingDirectory: AbsolutePath?,
29-
outputRedirection: OutputRedirection = .collect,
3029
startNewProcessGroup: Bool = true,
3130
loggingHandler: LoggingHandler? = .none
3231
) throws -> Process {
@@ -36,15 +35,13 @@ extension Process {
3635
arguments: arguments,
3736
environmentBlock: environmentBlock,
3837
workingDirectory: workingDirectory,
39-
outputRedirection: outputRedirection,
4038
startNewProcessGroup: startNewProcessGroup,
4139
loggingHandler: loggingHandler
4240
)
4341
} else {
4442
self.init(
4543
arguments: arguments,
4644
environmentBlock: environmentBlock,
47-
outputRedirection: outputRedirection,
4845
startNewProcessGroup: startNewProcessGroup,
4946
loggingHandler: loggingHandler
5047
)
@@ -60,7 +57,6 @@ extension Process {
6057
arguments: arguments,
6158
environmentBlock: environmentBlock,
6259
workingDirectory: nil,
63-
outputRedirection: outputRedirection,
6460
startNewProcessGroup: startNewProcessGroup,
6561
loggingHandler: loggingHandler
6662
)

Sources/SemanticIndex/CheckedIndex.swift

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

1313
import Foundation
14-
import IndexStoreDB
14+
@preconcurrency import IndexStoreDB
1515
import LSPLogging
1616
import LanguageServerProtocol
1717

@@ -47,7 +47,7 @@ public enum IndexCheckLevel {
4747
/// `IndexCheckLevel`.
4848
///
4949
/// - SeeAlso: Comment on `IndexOutOfDateChecker`
50-
public final class CheckedIndex: Sendable {
50+
public final class CheckedIndex {
5151
private var checker: IndexOutOfDateChecker
5252
private let index: IndexStoreDB
5353

@@ -56,6 +56,10 @@ public final class CheckedIndex: Sendable {
5656
self.checker = IndexOutOfDateChecker(checkLevel: checkLevel)
5757
}
5858

59+
public var unchecked: UncheckedIndex {
60+
return UncheckedIndex(index)
61+
}
62+
5963
@discardableResult
6064
public func forEachSymbolOccurrence(
6165
byUSR usr: String,
@@ -146,7 +150,7 @@ public final class CheckedIndex: Sendable {
146150
/// access of the underlying `IndexStoreDB`. This makes sure that accesses to the raw `IndexStoreDB` are explicit (by
147151
/// calling `underlyingIndexStoreDB`) and we don't accidentally call into the `IndexStoreDB` when we wanted a
148152
/// `CheckedIndex`.
149-
public struct UncheckedIndex {
153+
public struct UncheckedIndex: Sendable {
150154
public let underlyingIndexStoreDB: IndexStoreDB
151155

152156
public init?(_ index: IndexStoreDB?) {
@@ -156,6 +160,10 @@ public struct UncheckedIndex {
156160
self.underlyingIndexStoreDB = index
157161
}
158162

163+
public init(_ index: IndexStoreDB) {
164+
self.underlyingIndexStoreDB = index
165+
}
166+
159167
public func checked(for checkLevel: IndexCheckLevel) -> CheckedIndex {
160168
return CheckedIndex(index: underlyingIndexStoreDB, checkLevel: checkLevel)
161169
}

Sources/SemanticIndex/SemanticIndexManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public final actor SemanticIndexManager {
153153
UpdateIndexStoreTaskDescription(
154154
filesToIndex: Set(files),
155155
buildSystemManager: self.buildSystemManager,
156-
index: self.index,
156+
index: self.index.unchecked,
157157
didFinishCallback: { [weak self] taskDescription in
158158
self?.indexTaskDidFinish?(.updateIndexStore(taskDescription))
159159
}

Sources/SemanticIndex/UpdateIndexStoreTaskDescription.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import SKSupport
2020
import struct TSCBasic.AbsolutePath
2121
import class TSCBasic.Process
2222

23-
private var updateIndexStoreIDForLogging = AtomicUInt32(initialValue: 1)
23+
private nonisolated(unsafe) var updateIndexStoreIDForLogging = AtomicUInt32(initialValue: 1)
2424

2525
/// Describes a task to index a set of source files.
2626
///
@@ -36,7 +36,7 @@ public struct UpdateIndexStoreTaskDescription: TaskDescriptionProtocol {
3636

3737
/// A reference to the underlying index store. Used to check if the index is already up-to-date for a file, in which
3838
/// case we don't need to index it again.
39-
private let index: CheckedIndex
39+
private let index: UncheckedIndex
4040

4141
/// A callback that is called when the index task finishes
4242
private let didFinishCallback: @Sendable (UpdateIndexStoreTaskDescription) -> Void
@@ -57,7 +57,7 @@ public struct UpdateIndexStoreTaskDescription: TaskDescriptionProtocol {
5757
init(
5858
filesToIndex: Set<DocumentURI>,
5959
buildSystemManager: BuildSystemManager,
60-
index: CheckedIndex,
60+
index: UncheckedIndex,
6161
didFinishCallback: @escaping @Sendable (UpdateIndexStoreTaskDescription) -> Void
6262
) {
6363
self.filesToIndex = filesToIndex
@@ -122,7 +122,7 @@ public struct UpdateIndexStoreTaskDescription: TaskDescriptionProtocol {
122122
// The URI is not a file, so there's nothing we can index.
123123
return
124124
}
125-
guard !index.hasUpToDateUnit(for: url) else {
125+
guard !index.checked(for: .modifiedFiles).hasUpToDateUnit(for: url) else {
126126
// We consider a file's index up-to-date if we have any up-to-date unit. Changing build settings does not
127127
// invalidate the up-to-date status of the index.
128128
return

Sources/SourceKitD/SKDResponse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import CRT
2222
#endif
2323

2424
public final class SKDResponse: Sendable {
25-
private nonisolated let response: sourcekitd_api_response_t
25+
private nonisolated(unsafe) let response: sourcekitd_api_response_t
2626
let sourcekitd: SourceKitD
2727

2828
/// Creates a new `SKDResponse` that exclusively manages the raw `sourcekitd_api_response_t`.

Tests/SKCoreTests/ToolchainRegistryTests.swift

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,6 @@ final class ToolchainRegistryTests: XCTestCase {
3636
await assertTrue(tr.default === tr.toolchain(identifier: "a"))
3737
}
3838

39-
func testDefaultDarwin() async throws {
40-
let prevPlatform = Platform.current
41-
defer { Platform.current = prevPlatform }
42-
Platform.current = .darwin
43-
44-
let tr = ToolchainRegistry(
45-
toolchains: [
46-
Toolchain(identifier: "a", displayName: "a", path: nil),
47-
Toolchain(identifier: ToolchainRegistry.darwinDefaultToolchainIdentifier, displayName: "a", path: nil),
48-
]
49-
)
50-
await assertEqual(tr.default?.identifier, ToolchainRegistry.darwinDefaultToolchainIdentifier)
51-
}
52-
53-
func testUnknownPlatform() throws {
54-
let prevPlatform = Platform.current
55-
defer { Platform.current = prevPlatform }
56-
Platform.current = nil
57-
58-
let fs = InMemoryFileSystem()
59-
let binPath = try AbsolutePath(validating: "/foo/bar/my_toolchain/bin")
60-
try makeToolchain(binPath: binPath, fs, sourcekitdInProc: true)
61-
62-
guard let t = Toolchain(binPath, fs) else {
63-
XCTFail("could not find any tools")
64-
return
65-
}
66-
XCTAssertNotNil(t.sourcekitd)
67-
}
68-
6939
func testFindXcodeDefaultToolchain() async throws {
7040
try SkipUnless.platformIsDarwin("Finding toolchains in Xcode is only supported on macOS")
7141
let fs = InMemoryFileSystem()

0 commit comments

Comments
 (0)