Skip to content

Forbid direct usage of Endpoint in user code

Ivan “CLOVIS” Canet requested to merge api-compatibility-inheritance into main

Currently (dd39da37), the project has the downside that the Endpoint type has multiple type parameters. It is likely that we will want to add new type parameters in the future. Adding type parameters is a binary-compatible change. However, if the user has explicitly written Endpoint<T1, T2, T3> anywhere, that code will stop compiling.

In the prototype, this has been considered an acceptable downside, since Kotlin's type inference makes specifying the type optional:

object Users : StaticResource("users") {
    val list by get()
        .response<List<UserDto>>()
}

In that example, list had type Endpoint<Unit, List<UserDto>, Parameters.Empty>. However, since the type was not written explicitly, it would not break when more type parameters would be added.

This MR is an attempt at forbidding the user from writing the type at all. The Endpoint class is marked as deprecated, and AnyEndpoint is used as a super-type. The compiler doesn't warn for inferred usages of a deprecated type when it has a non-deprecated supertype.

Merge request reports