Skip to content

Connection: add default impls so old conformers keep working#69

Merged
rintaro merged 1 commit into
swiftlang:mainfrom
rintaro:connection-send-default-impl
Jun 25, 2026
Merged

Connection: add default impls so old conformers keep working#69
rintaro merged 1 commit into
swiftlang:mainfrom
rintaro:connection-send-default-impl

Conversation

@rintaro

@rintaro rintaro commented Jun 24, 2026

Copy link
Copy Markdown
Member

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.

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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@rintaro rintaro force-pushed the connection-send-default-impl branch from 38d2c45 to f3ba2a9 Compare June 25, 2026 18:16
@rintaro rintaro merged commit 0a4bf63 into swiftlang:main Jun 25, 2026
53 checks passed
@rintaro rintaro deleted the connection-send-default-impl branch June 26, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants