Kotlin: variadic (auto-infer) type arguments possible?

Viewed 377

I understood how basic type inference works in Kotlin, but i wonder if i can only call a function with either all type arguments or none of them, or if i can define variable type arguments somehow; EG:

fun<A: SomeClass1, B: SomeClass2, T: SomeTuple<A,B>> foo(t:SomeTuple<A,B>?=null) = doSomething<A,B,T>(t)

this function can either be called via foo(someTuple) or foo<SomeClass1,SomeClass2,SomeTuple<Someclass1,SomeClass2>>(), while it's clear that the first two type arguments are inferable from the last;

Is it possible to do something like foo<SomeTuple<Someclass1,SomeClass2>>() and still be able to infer and use A and B inside the function body

0 Answers
Related