I expected fun foo(varargs i: Int) to translate to void foo(java.lang.Integer... i), but it translates to void foo(int... i) and indeed the parameter is an IntArray and not an Array<Int>.
Nothing is wrong with this optimization, I just mention it because it slightly suprised me.
The bytecode Kotlin produces is now somewhat unique when you do method overloading.
Since JDK 7 the compiler would not allow you to do this:
void foo(int… i)
void foo(Object… o) // Allowed with JDK 6, ambiguous reference with JDK 7
The reason is simple:
The compiler selects the most-specific method when more than one method is applicable.
But it should not be possible to choose between
intis a subtype of
Objectis a subtype of
As far as Kotlin and the JVM concerned it is all right to do it of course, so there is not much to talk about.