Hello! I've updated Kotlin compiler to 1.7.0 version and want to use underscore operator for template parameters type infer in such code:
Copy code
abstract class SomeClass<T> {
abstract fun execute(): T
}
class SomeImplementation : SomeClass<String>() {
override fun execute(): String = "Test"
}
open class Test<S: SomeClass<T>, T>
class Test1 : Test<SomeImplementation, _>() // compiler complains about Unresolved reference: _
d
dmitriy.novozhilov
07/20/2022, 4:02 PM
You can use underscore only in explicit type arguments of function calls in bodies
p
PHondogo
07/20/2022, 4:03 PM
Is there any reason for such limitation?
d
dmitriy.novozhilov
07/21/2022, 7:40 AM
Support of
_
was introduced only to place where compiler uses type inference. In supertypes list there is no inference, compiler just uses specified type arguments
p
PHondogo
07/21/2022, 7:43 AM
It's a pity.
d
dmitriy.novozhilov
07/21/2022, 7:46 AM
Yeah, I know. We are aware of some boilerplate in specifying type arguments of super types and want to found some way to get rid of it, but right now we have more important things to do