public inline fun <reified OUT, IN> test(input: IN) {}
fun main() {
// Why input type is not recognized? Why is forcing me to defined input type again in diamond bracket???
test<TableInfo>(input = String())
// And now its working
test<TableInfo, String>(input = String())
}
Is this limitation of inline reified functions, or is it a bug?
How could the compiler know you provided the OUT and not IN? Kotlin definitely could do better here, but as for now, we can do this: test<TableInfo, _>.
BTW, imgae is worth 1000 words, but it doesn’t help the reader to reproduce your problem and ultimately, help you solve your problem
It would be cool if you could mark generic type with some anotation so that compiler knows
which types he chould infere from the usage… For example like this…
public inline fun <reified OUT, infered IN> test(output: KClass<OUT>, input: IN){}
fun main(){
test<TableInfo>(String())
}
Should I make feature request on kotlin youtrack? What you guys think?