Expect you have an interface like this:
interface MyInterface<T : BaseClass<I>, I> {
fun someMethod(param: I) : T
}
As you can see I use I
as a parameter in someMethod
. But actually I don't want to declare I
when I implement this interface like this:
class BaseClassImpl : BaseClass<OtherClass>
class Impl : MyInterface<BaseClassImpl, OtherClass> {
override fun someMethod(param: OtherClass) {
TODO("Not yet implemented")
}
}
Theoretically it should be possible that the I
generic can be resolved by the compiler without the additional declaration because it's provided by BaseClassImpl
. So MyInterface<BaseClassImpl>
should already provide enough information to resolve the necessary generic for someMethod()
.
Is there any way to achieve that in Kotlin?