Hi there,
The following code generate a compiler Error:(6, 41) Kotlin: Type inference failed. Expected type mismatch: inferred type is Class<CmdEcho<*>> but Class<out CmdEcho> was expected
What is a proper way to pass CmdEcho
to function call
?
package com.cuma.kotlin
class TestG<X> {
fun test(): CmdEcho<X> {
val util = CmdUtil<CmdEcho<X>>()
return util.call(CmdEcho::class.java)
}
}
class CmdUtil<Y> {
fun call(x: Class<out Y>): Y {
return x.newInstance()
}
}
class CmdEcho<X> {
}
Thanks
Simon