I have two method in java:
Object get(A a)
Object get(A a, B... b)
and when I'm trying to invoke first method in Kotlin
get(someInstance)
It always invokes second method with empty second parameter.
How could I call first method from Kotlin in this case?
First of all, this doesn't happen when methods are defined in Kotlin:
class A
class B
fun f(a: A) { println("one") }
fun f(a: A, vararg rest: B) { println("many") }
fun main(args: Array<String>) {
f(A())
}
prints one. Searching on https://youtrack.jetbrains.com/issues?q=kotlin%20vararg%20java I can't find this exact issue (https://youtrack.jetbrains.com/issue/KT-11150 is close, but it has get(Object a) as the non-vararg overload). So I suggest you post it there if you can reproduce it.
Two possible workarounds:
trying to adapt a trick from Kotlin function overloading (varargs vs single parameter):
val a: A = ...
a.let(::get)
define a wrapper in Java:
Object getNonVararg(A a) { return get(a); }
and call it from Kotlin.