diff --git a/Sources/Diagnose/CMakeLists.txt b/Sources/Diagnose/CMakeLists.txt index 4fc6aff33..cca945242 100644 --- a/Sources/Diagnose/CMakeLists.txt +++ b/Sources/Diagnose/CMakeLists.txt @@ -1,5 +1,4 @@ add_library(Diagnose STATIC - CommandConfiguration+Sendable.swift CommandLineArgumentsReducer.swift DebugCommand.swift DiagnoseCommand.swift diff --git a/Sources/Diagnose/CommandConfiguration+Sendable.swift b/Sources/Diagnose/CommandConfiguration+Sendable.swift deleted file mode 100644 index 0504351e5..000000000 --- a/Sources/Diagnose/CommandConfiguration+Sendable.swift +++ /dev/null @@ -1,21 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift.org open source project -// -// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors -// Licensed under Apache License v2.0 with Runtime Library Exception -// -// See https://swift.org/LICENSE.txt for license information -// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors -// -//===----------------------------------------------------------------------===// - -import ArgumentParser - -// If `CommandConfiguration` is not sendable, commands can't have static `configuration` properties. -// Needed until we update Swift CI to swift-argument-parser 1.3.1, which has this conformance (rdar://128042447). -#if compiler(<5.11) -extension CommandConfiguration: @unchecked Sendable {} -#else -extension CommandConfiguration: @unchecked @retroactive Sendable {} -#endif diff --git a/Sources/SKTestSupport/RepeatUntilExpectedResult.swift b/Sources/SKTestSupport/RepeatUntilExpectedResult.swift index a421645e4..ab25de52d 100644 --- a/Sources/SKTestSupport/RepeatUntilExpectedResult.swift +++ b/Sources/SKTestSupport/RepeatUntilExpectedResult.swift @@ -10,7 +10,6 @@ // //===----------------------------------------------------------------------===// -import SKTestSupport import XCTest /// Runs the body repeatedly once per second until it returns `true`, giving up after `timeout`. diff --git a/Sources/SKTestSupport/WrappedSemaphore.swift b/Sources/SKTestSupport/WrappedSemaphore.swift index 52bad1b1e..c768d2bdd 100644 --- a/Sources/SKTestSupport/WrappedSemaphore.swift +++ b/Sources/SKTestSupport/WrappedSemaphore.swift @@ -11,7 +11,6 @@ //===----------------------------------------------------------------------===// import Dispatch -import SKTestSupport import XCTest /// Wrapper around `DispatchSemaphore` so that Swift Concurrency doesn't complain about the usage of semaphores in the diff --git a/Sources/SourceKitD/DynamicallyLoadedSourceKitD.swift b/Sources/SourceKitD/DynamicallyLoadedSourceKitD.swift index ab633b9a3..e68eed2b9 100644 --- a/Sources/SourceKitD/DynamicallyLoadedSourceKitD.swift +++ b/Sources/SourceKitD/DynamicallyLoadedSourceKitD.swift @@ -85,7 +85,7 @@ package actor DynamicallyLoadedSourceKitD: SourceKitD { self.api.shutdown() // FIXME: is it safe to dlclose() sourcekitd? If so, do that here. For now, let the handle leak. Task.detached(priority: .background) { [dylib] in - await dylib.leak() + dylib.leak() } } diff --git a/Sources/SourceKitD/SourceKitD.swift b/Sources/SourceKitD/SourceKitD.swift index 0f9dde69a..f7d2cb00f 100644 --- a/Sources/SourceKitD/SourceKitD.swift +++ b/Sources/SourceKitD/SourceKitD.swift @@ -15,11 +15,10 @@ import Dispatch import Foundation import SwiftExtensions -#if compiler(>=6) -extension sourcekitd_api_request_handle_t: @retroactive @unchecked Sendable {} -#else -extension sourcekitd_api_request_handle_t: @unchecked Sendable {} -#endif +fileprivate struct SourceKitDRequestHandle: Sendable { + /// `nonisolated(unsafe)` is fine because we just use the handle as an opaque value. + nonisolated(unsafe) let handle: sourcekitd_api_request_handle_t +} /// Access to sourcekitd API, taking care of initialization, shutdown, and notification handler /// multiplexing. @@ -107,16 +106,19 @@ extension SourceKitD { log(request: request) let sourcekitdResponse = try await withTimeout(timeout) { - return try await withCancellableCheckedThrowingContinuation { continuation in + return try await withCancellableCheckedThrowingContinuation { (continuation) -> SourceKitDRequestHandle? in var handle: sourcekitd_api_request_handle_t? = nil self.api.send_request(request.dict, &handle) { response in continuation.resume(returning: SKDResponse(response!, sourcekitd: self)) } - return handle - } cancel: { handle in + if let handle { + return SourceKitDRequestHandle(handle: handle) + } + return nil + } cancel: { (handle: SourceKitDRequestHandle?) in if let handle { self.logRequestCancellation(request: request) - self.api.cancel_request(handle) + self.api.cancel_request(handle.handle) } } } diff --git a/Sources/SourceKitLSP/Rename.swift b/Sources/SourceKitLSP/Rename.swift index f15dd04b5..5600ce889 100644 --- a/Sources/SourceKitLSP/Rename.swift +++ b/Sources/SourceKitLSP/Rename.swift @@ -10,7 +10,7 @@ // //===----------------------------------------------------------------------===// -@preconcurrency import IndexStoreDB +import IndexStoreDB import LanguageServerProtocol import SKLogging import SKSupport diff --git a/Sources/SourceKitLSP/Swift/CodeActions/PackageManifestEdits.swift b/Sources/SourceKitLSP/Swift/CodeActions/PackageManifestEdits.swift index 870ab95a1..b5e0b2106 100644 --- a/Sources/SourceKitLSP/Swift/CodeActions/PackageManifestEdits.swift +++ b/Sources/SourceKitLSP/Swift/CodeActions/PackageManifestEdits.swift @@ -35,7 +35,7 @@ struct PackageManifestEdits: SyntaxCodeActionProvider { ) -> [CodeAction] { do { var actions: [CodeAction] = [] - let variants: [(TargetDescription.TargetType, String)] = [ + let variants: [(TargetDescription.TargetKind, String)] = [ (.regular, "library"), (.executable, "executable"), (.macro, "macro"), diff --git a/Tests/SourceKitLSPTests/DocumentSymbolTests.swift b/Tests/SourceKitLSPTests/DocumentSymbolTests.swift index a0420c15c..ec39e4bb9 100644 --- a/Tests/SourceKitLSPTests/DocumentSymbolTests.swift +++ b/Tests/SourceKitLSPTests/DocumentSymbolTests.swift @@ -762,7 +762,7 @@ final class DocumentSymbolTests: XCTestCase { fileprivate func assertDocumentSymbols( _ markedText: String, _ expectedDocumentSymbols: (DocumentPositions) -> [DocumentSymbol], - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) async throws { let testClient = try await TestSourceKitLSPClient() diff --git a/Tests/SourceKitLSPTests/FoldingRangeTests.swift b/Tests/SourceKitLSPTests/FoldingRangeTests.swift index c594ffdd6..ff89a85f8 100644 --- a/Tests/SourceKitLSPTests/FoldingRangeTests.swift +++ b/Tests/SourceKitLSPTests/FoldingRangeTests.swift @@ -44,7 +44,7 @@ func assertFoldingRanges( expectedRanges: [FoldingRangeSpec], rangeLimit: Int? = nil, lineFoldingOnly: Bool = false, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) async throws { let capabilities = ClientCapabilities( diff --git a/Tests/SourceKitLSPTests/HoverTests.swift b/Tests/SourceKitLSPTests/HoverTests.swift index 02376ad08..0936b4369 100644 --- a/Tests/SourceKitLSPTests/HoverTests.swift +++ b/Tests/SourceKitLSPTests/HoverTests.swift @@ -176,7 +176,7 @@ final class HoverTests: XCTestCase { private func assertHover( _ markedSource: String, expectedContent: String, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) async throws { let testClient = try await TestSourceKitLSPClient() diff --git a/Tests/SourceKitLSPTests/RenameAssertions.swift b/Tests/SourceKitLSPTests/RenameAssertions.swift index 0c476aa4e..209f0f02a 100644 --- a/Tests/SourceKitLSPTests/RenameAssertions.swift +++ b/Tests/SourceKitLSPTests/RenameAssertions.swift @@ -39,7 +39,7 @@ func assertSingleFileRename( expectedPrepareRenamePlaceholder: String, expected: String, testName: String = #function, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) async throws { try await SkipUnless.sourcekitdSupportsRename() @@ -99,7 +99,7 @@ func assertRenamedSourceMatches( in ws: MultiFileTestProject, message: String, testName: String = #function, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) throws { for (expectedFileLocation, expectedRenamed) in expected { @@ -138,7 +138,7 @@ func assertMultiFileRename( manifest: String = SwiftPMTestProject.defaultPackageManifest, preRenameActions: (SwiftPMTestProject) throws -> Void = { _ in }, testName: String = #function, - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) async throws { try await SkipUnless.sourcekitdSupportsRename() diff --git a/Tests/SourceKitLSPTests/TypeHierarchyTests.swift b/Tests/SourceKitLSPTests/TypeHierarchyTests.swift index a7ac1242f..1b9433a9e 100644 --- a/Tests/SourceKitLSPTests/TypeHierarchyTests.swift +++ b/Tests/SourceKitLSPTests/TypeHierarchyTests.swift @@ -225,7 +225,7 @@ fileprivate extension TypeHierarchyItem { fileprivate func assertEqualIgnoringData( _ actual: [TypeHierarchyItem]?, _ expected: [TypeHierarchyItem], - file: StaticString = #file, + file: StaticString = #filePath, line: UInt = #line ) { guard let actual else {