Skip to content

Commit 6b19657

Browse files
committed
Enable ExistentialAny
1 parent c1414a7 commit 6b19657

File tree

57 files changed

+190
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+190
-182
lines changed

Package.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ import PackageDescription
66
/// Swift settings that should be applied to every Swift target.
77
var globalSwiftSettings: [SwiftSetting] {
88
var result: [SwiftSetting] = [
9+
// Swift 7 mode upcoming features. These must be compatible with swift-tools-version.
910
.enableUpcomingFeature("InternalImportsByDefault"),
1011
.enableUpcomingFeature("MemberImportVisibility"),
1112
.enableUpcomingFeature("InferIsolatedConformances"),
1213
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
14+
.enableUpcomingFeature("ExistentialAny"),
15+
16+
// Warning escalation.
17+
.unsafeFlags(["-Werror", "ExistentialAny"]),
1318
]
1419
if noSwiftPMDependency {
1520
result += [.define("NO_SWIFTPM_DEPENDENCY")]

Sources/BuildServerIntegration/BuildServerManager.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ private extension BuildServerSpec {
205205
private func createBuiltInBuildServerAdapter(
206206
messagesToSourceKitLSPHandler: any MessageHandler,
207207
buildServerHooks: BuildServerHooks,
208-
_ createBuildServer: @Sendable (_ connectionToSourceKitLSP: any Connection) async throws -> BuiltInBuildServer?
208+
_ createBuildServer:
209+
@Sendable (
210+
_ connectionToSourceKitLSP: any Connection
211+
) async throws -> (any BuiltInBuildServer)?
209212
) async -> BuildServerAdapter? {
210213
let connectionToSourceKitLSP = LocalConnection(
211214
receiverName: "BuildServerManager for \(projectRoot.lastPathComponent)",
@@ -327,7 +330,7 @@ package actor BuildServerManager: QueueBasedMessageHandler {
327330
/// get `fileBuildSettingsChanged` and `filesDependenciesUpdated` callbacks.
328331
private var watchedFiles: [DocumentURI: (mainFile: DocumentURI, language: Language)] = [:]
329332

330-
private var connectionToClient: BuildServerManagerConnectionToClient
333+
private var connectionToClient: any BuildServerManagerConnectionToClient
331334

332335
/// The build serer adapter that is used to answer build server queries.
333336
private var buildServerAdapter: BuildServerAdapter?
@@ -347,7 +350,7 @@ package actor BuildServerManager: QueueBasedMessageHandler {
347350
/// Provider of file to main file mappings.
348351
///
349352
/// Force-unwrapped optional because initializing it requires access to `self`.
350-
private var mainFilesProvider: Task<MainFilesProvider?, Never>! {
353+
private var mainFilesProvider: Task<(any MainFilesProvider)?, Never>! {
351354
didSet {
352355
// Must only be set once
353356
precondition(oldValue == nil)
@@ -367,7 +370,7 @@ package actor BuildServerManager: QueueBasedMessageHandler {
367370
}
368371

369372
/// Build server delegate that will receive notifications about setting changes, etc.
370-
private weak var delegate: BuildServerManagerDelegate?
373+
private weak var delegate: (any BuildServerManagerDelegate)?
371374

372375
private let buildSettingsLogger = BuildSettingsLogger()
373376

@@ -485,12 +488,12 @@ package actor BuildServerManager: QueueBasedMessageHandler {
485488
buildServerSpec: BuildServerSpec?,
486489
toolchainRegistry: ToolchainRegistry,
487490
options: SourceKitLSPOptions,
488-
connectionToClient: BuildServerManagerConnectionToClient,
491+
connectionToClient: any BuildServerManagerConnectionToClient,
489492
buildServerHooks: BuildServerHooks,
490493
createMainFilesProvider:
491494
@escaping @Sendable (
492495
SourceKitInitializeBuildResponseData?, _ mainFilesChangedCallback: @escaping @Sendable () async -> Void
493-
) async -> MainFilesProvider?
496+
) async -> (any MainFilesProvider)?
494497
) async {
495498
self.toolchainRegistry = toolchainRegistry
496499
self.options = options
@@ -656,7 +659,7 @@ package actor BuildServerManager: QueueBasedMessageHandler {
656659

657660
/// - Note: Needed because `BuildSererManager` is created before `Workspace` is initialized and `Workspace` needs to
658661
/// create the `BuildServerManager`, then initialize itself and then set itself as the delegate.
659-
package func setDelegate(_ delegate: BuildServerManagerDelegate?) {
662+
package func setDelegate(_ delegate: (any BuildServerManagerDelegate)?) {
660663
self.delegate = delegate
661664
}
662665

Sources/BuildServerIntegration/BuiltInBuildServerAdapter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ actor BuiltInBuildServerAdapter: QueueBasedMessageHandler {
5959
package let messageHandlingQueue = AsyncQueue<BuildServerMessageDependencyTracker>()
6060

6161
/// The underlying build server
62-
private var underlyingBuildServer: BuiltInBuildServer
62+
private var underlyingBuildServer: any BuiltInBuildServer
6363

6464
/// The connection with which messages are sent to `BuildServerManager`.
6565
private let connectionToSourceKitLSP: LocalConnection
@@ -69,7 +69,7 @@ actor BuiltInBuildServerAdapter: QueueBasedMessageHandler {
6969
/// Create a `BuiltInBuildServerAdapter` form an existing `BuiltInBuildServer` and connection to communicate messages
7070
/// from the build server to SourceKit-LSP.
7171
init(
72-
underlyingBuildServer: BuiltInBuildServer,
72+
underlyingBuildServer: any BuiltInBuildServer,
7373
connectionToSourceKitLSP: LocalConnection,
7474
buildServerHooks: BuildServerHooks
7575
) {

Sources/BuildServerIntegration/CompilationDatabase.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ package struct CompilationDatabaseCompileCommand: Equatable, Codable {
5252
case output
5353
}
5454

55-
package init(from decoder: Decoder) throws {
55+
package init(from decoder: any Decoder) throws {
5656
let container = try decoder.container(keyedBy: CodingKeys.self)
5757
self.directory = try container.decode(String.self, forKey: .directory)
5858
self.filename = try container.decode(String.self, forKey: .file)
@@ -70,7 +70,7 @@ package struct CompilationDatabaseCompileCommand: Equatable, Codable {
7070
}
7171
}
7272

73-
package func encode(to encoder: Encoder) throws {
73+
package func encode(to encoder: any Encoder) throws {
7474
var container = encoder.container(keyedBy: CodingKeys.self)
7575
try container.encode(directory, forKey: .directory)
7676
try container.encode(filename, forKey: .file)
@@ -140,7 +140,7 @@ package struct JSONCompilationDatabase: Equatable, Codable {
140140
///
141141
/// A `URL` representing the directory that contains the `compile_commands.json` must be passed in the decoder's
142142
/// `userInfo` via the `compileCommandsDirectoryKey`.
143-
package init(from decoder: Decoder) throws {
143+
package init(from decoder: any Decoder) throws {
144144
guard let compileCommandsDirectory = decoder.userInfo[.compileCommandsDirectoryKey] as? URL else {
145145
struct MissingCompileCommandsDirectoryKeyError: Error {}
146146
throw MissingCompileCommandsDirectoryKeyError()
@@ -169,7 +169,7 @@ package struct JSONCompilationDatabase: Equatable, Codable {
169169
self = try decoder.decode(JSONCompilationDatabase.self, from: data)
170170
}
171171

172-
package func encode(to encoder: Encoder) throws {
172+
package func encode(to encoder: any Encoder) throws {
173173
var container = encoder.unkeyedContainer()
174174
for command in commands {
175175
try container.encode(command)

Sources/BuildServerIntegration/ExternalBuildServerAdapter.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ actor ExternalBuildServerAdapter {
9393
private let configPath: URL
9494

9595
/// The `BuildServerManager` that handles messages from the BSP server to SourceKit-LSP.
96-
var messagesToSourceKitLSPHandler: MessageHandler
96+
var messagesToSourceKitLSPHandler: any MessageHandler
9797

9898
/// The JSON-RPC connection between SourceKit-LSP and the BSP server.
9999
private(set) var connectionToBuildServer: JSONRPCConnection?
@@ -124,7 +124,7 @@ actor ExternalBuildServerAdapter {
124124
init(
125125
projectRoot: URL,
126126
configPath: URL,
127-
messagesToSourceKitLSPHandler: MessageHandler
127+
messagesToSourceKitLSPHandler: any MessageHandler
128128
) async throws {
129129
self.projectRoot = projectRoot
130130
self.configPath = configPath
@@ -135,7 +135,7 @@ actor ExternalBuildServerAdapter {
135135
/// Change the handler that handles messages from the build server.
136136
///
137137
/// The intended use of this is to intercept messages from the build server by `LegacyBuildServer`.
138-
func changeMessageToSourceKitLSPHandler(to newHandler: MessageHandler) {
138+
func changeMessageToSourceKitLSPHandler(to newHandler: any MessageHandler) {
139139
messagesToSourceKitLSPHandler = newHandler
140140
connectionToBuildServer?.changeReceiveHandler(messagesToSourceKitLSPHandler)
141141
}

Sources/BuildServerIntegration/SwiftPMBuildServer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ package actor SwiftPMBuildServer: BuiltInBuildServer {
135135
private var buildDescription: SourceKitLSPAPI.BuildDescription?
136136

137137
/// Maps target ids to their SwiftPM build target.
138-
private var swiftPMTargets: [BuildTargetIdentifier: SwiftBuildTarget] = [:]
138+
private var swiftPMTargets: [BuildTargetIdentifier: any SwiftBuildTarget] = [:]
139139

140140
private var targetDependencies: [BuildTargetIdentifier: Set<BuildTargetIdentifier>] = [:]
141141

Sources/BuildServerIntegration/SwiftlyResolver.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ actor SwiftlyResolver {
2727
let workingDirectory: URL?
2828
}
2929

30-
private var cache: LRUCache<CacheKey, Result<URL?, Error>> = LRUCache(capacity: 100)
30+
private var cache: LRUCache<CacheKey, Result<URL?, any Error>> = LRUCache(capacity: 100)
3131

3232
/// Check if `compiler` is a symlink to `swiftly`. If so, find the executable in the toolchain that swiftly resolves
3333
/// to within the given working directory and return the URL of the corresponding compiler in that toolchain.
@@ -37,7 +37,7 @@ actor SwiftlyResolver {
3737
if let cached = cache[cacheKey] {
3838
return try cached.get()
3939
}
40-
let computed: Result<URL?, Error>
40+
let computed: Result<URL?, any Error>
4141
do {
4242
computed = .success(
4343
try await resolveSwiftlyTrampolineImpl(compiler: compiler, workingDirectory: workingDirectory)

Sources/ClangLanguageService/ClangLanguageService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ package actor ClangLanguageService: LanguageService, MessageHandler {
5454
private weak var sourceKitLSPServer: SourceKitLSPServer?
5555

5656
/// The connection to the clangd LSP. `nil` until `startClangdProcesss` has been called.
57-
var clangd: Connection!
57+
var clangd: (any Connection)!
5858

5959
/// Capabilities of the clangd LSP, if received.
6060
var capabilities: ServerCapabilities? = nil

Sources/CompletionScoring/Semantics/SemanticClassification.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ package struct SemanticClassification: Equatable {
7676
package let scoreComponent: Double
7777
}
7878

79-
private var scoreComponents: [CompletionScoreComponent] {
79+
private var scoreComponents: [any CompletionScoreComponent] {
8080
return [
8181
availability,
8282
completionKind,

Sources/Diagnose/CommandLineArgumentsReducer.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Foundation
1818
extension RequestInfo {
1919
@MainActor
2020
func reduceCommandLineArguments(
21-
using executor: SourceKitRequestExecutor,
21+
using executor: any SourceKitRequestExecutor,
2222
progressUpdate: (_ progress: Double, _ message: String) -> Void
2323
) async throws -> RequestInfo {
2424
try await withoutActuallyEscaping(progressUpdate) { progressUpdate in
@@ -34,7 +34,7 @@ extension RequestInfo {
3434
private class CommandLineArgumentReducer {
3535
/// The executor that is used to run a sourcekitd request and check whether it
3636
/// still crashes.
37-
private let sourcekitdExecutor: SourceKitRequestExecutor
37+
private let sourcekitdExecutor: any SourceKitRequestExecutor
3838

3939
/// A callback to be called when the reducer has made progress reducing the request
4040
private let progressUpdate: (_ progress: Double, _ message: String) -> Void
@@ -43,7 +43,7 @@ private class CommandLineArgumentReducer {
4343
private var initialCommandLineCount: Int = 0
4444

4545
init(
46-
sourcekitdExecutor: SourceKitRequestExecutor,
46+
sourcekitdExecutor: any SourceKitRequestExecutor,
4747
progressUpdate: @escaping (_ progress: Double, _ message: String) -> Void
4848
) {
4949
self.sourcekitdExecutor = sourcekitdExecutor

0 commit comments

Comments
 (0)