Connection: add default impls so old conformers keep working#69
Merged
Merged
Conversation
hamishknight
approved these changes
Jun 25, 2026
Comment on lines
+59
to
+67
| self.send(request, id: id, reply: reply) | ||
| } | ||
|
|
||
| public func send<Request: RequestType>( | ||
| _ request: Request, | ||
| id: RequestID, | ||
| reply: @escaping @Sendable (LSPResult<Request.Response>) -> Void | ||
| ) { | ||
| self.send(request, method: Request.method, id: id, reply: reply) |
Contributor
There was a problem hiding this comment.
Can't say I love the fact that implementing neither will result in infinite recursion instead of a compiler error, would it make sense to at least mark the default implementation of the method variant as deprecated? That way conformers at least get a warning if they don't implement it (if they previously implemented the non-method variant they should just add the method parameter)
Add `send(_:id:reply:)` back as a protocol requirement alongside the `method:`-overriding variant introduced in 0b3ca2a. Both have default extension implementations that bridge to each other, so a conformer that implements either one satisfies the protocol. Conformers that only had the original signature continue to compile unchanged. They lose the ability to honor a `method:` override, which is acceptable since only transport-level connections (LocalConnection, JSONRPCConnection, LegacyNameFallbackConnection) need that capability and they implement the new signature directly.
38d2c45 to
f3ba2a9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
send(_:id:reply:)back as a protocol requirement alongside themethod:-overriding variant introduced in 0b3ca2a. Both have default extension implementations that bridge to each other, so a conformer that implements either one satisfies the protocol.Conformers that only had the original signature continue to compile unchanged. They lose the ability to honor a
method:override, which is acceptable since only transport-level connections (LocalConnection, JSONRPCConnection, LegacyNameFallbackConnection) need that capability and they implement the new signature directly.