Hey everyone! I have a mechanism with a bunch of g...
# codereview
d
Hey everyone! I have a mechanism with a bunch of generics, like that
Copy code
open 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
Copy code
fun main() {
    Outside(InsideImpl::class)
}
But it doesn't when I extend it
Copy code
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
Copy code
class OutsideImpl: Outside<InsideImpl, Int, String>(InsideImpl::class) {
}
Any idea how I could write it differently so it can be inferred by Kotlin?