Skip to content

Commit b1ff059

Browse files
committed
Add sendable annotation to userInfo closure
swift-foundation recently landed a change (in swiftlang/swift-foundation#764) which requires `any Sendable` values in `JSONEncoder.userInfo`. This causes a build failure: ``` JSONRPCConnection.swift:370:50: error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol 368 | 369 | // Setup callback for response type. 370 | decoder.userInfo[.responseTypeCallbackKey] = { (id: RequestID) -> ResponseType.Type? in | |- error: type '(RequestID) -> Optional<any ResponseType.Type>' does not conform to the 'Sendable' protocol | `- note: a function type must be marked '@sendable' to conform to 'Sendable' 371 | guard let outstanding = self.outstandingRequests[id] else { 372 | logger.error("Unknown request for \(id, privacy: .public)") ``` Make the closure sendable (the decoding here is already guarded by a queue).
1 parent 94ba7ea commit b1ff059

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/LanguageServerProtocolJSONRPC/JSONRPCConnection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public final class JSONRPCConnection: Connection {
367367
decoder.userInfo[.messageRegistryKey] = messageRegistry
368368

369369
// Setup callback for response type.
370-
decoder.userInfo[.responseTypeCallbackKey] = { (id: RequestID) -> ResponseType.Type? in
370+
decoder.userInfo[.responseTypeCallbackKey] = { @Sendable (id: RequestID) -> ResponseType.Type? in
371371
guard let outstanding = self.outstandingRequests[id] else {
372372
logger.error("Unknown request for \(id, privacy: .public)")
373373
return nil

0 commit comments

Comments
 (0)