David Bertet
06/12/2020, 5:10 PMopen class Inside<T, V> {
}
open class Outside<T: Inside<V, S>, V, S>(infered: KClass<T>) {
}
class InsideImpl: Inside<Int, String>() {
}
Kotlin is able to infer types when I instantiate the class
fun main() {
Outside(InsideImpl::class)
}
But it doesn't when I extend it
class OutsideImpl: Outside(InsideImpl::class) { // ERROR: 3 type arguments expected for class Outside<T : Inside<V, S>, V, S>
}
I have to make everything explicit, which is a bit annoying as I have lot of generics to repeat in multiple layers
class OutsideImpl: Outside<InsideImpl, Int, String>(InsideImpl::class) {
}
Any idea how I could write it differently so it can be inferred by Kotlin?