Skip to content

Commit a6c236e

Browse files
committed
Work around a compiler assertion failure rdar://116221716
1 parent 0ce6802 commit a6c236e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Sources/SourceKitLSP/Swift/SwiftLanguageServer.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,15 @@ public actor SwiftLanguageServer: ToolchainLanguageServer {
136136

137137
private var stateChangeHandlers: [(_ oldState: LanguageServerState, _ newState: LanguageServerState) -> Void] = []
138138

139-
private let diagnosticReportManager: DiagnosticReportManager
139+
private var diagnosticReportManager: DiagnosticReportManager!
140+
141+
/// Only exists to work around rdar://116221716.
142+
/// Once that is fixed, remove the property and make `diagnosticReportManager` non-optional.
143+
private var clientHasDiagnosticsCodeDescriptionSupport: Bool {
144+
get async {
145+
return await capabilityRegistry.clientHasDiagnosticsCodeDescriptionSupport
146+
}
147+
}
140148

141149
/// Creates a language server for the given client using the sourcekitd dylib specified in `toolchain`.
142150
/// `reopenDocuments` is a closure that will be called if sourcekitd crashes and the `SwiftLanguageServer` asks its parent server to reopen all of its documents.
@@ -157,11 +165,12 @@ public actor SwiftLanguageServer: ToolchainLanguageServer {
157165
self.state = .connected
158166
self.generatedInterfacesPath = options.generatedInterfacesPath.asURL
159167
try FileManager.default.createDirectory(at: generatedInterfacesPath, withIntermediateDirectories: true)
168+
self.diagnosticReportManager = nil // Needed to work around rdar://116221716
160169
self.diagnosticReportManager = DiagnosticReportManager(
161170
sourcekitd: self.sourcekitd,
162171
syntaxTreeManager: syntaxTreeManager,
163172
documentManager: documentManager,
164-
clientHasDiagnosticsCodeDescriptionSupport: await capabilityRegistry.clientHasDiagnosticsCodeDescriptionSupport
173+
clientHasDiagnosticsCodeDescriptionSupport: await self.clientHasDiagnosticsCodeDescriptionSupport
165174
)
166175
}
167176

0 commit comments

Comments
 (0)