Pass-through varargs

No, the problem is not in Kotlin, it is in the fact that String.format is fundamentally type unsafe (GCC/CLang have options for C/C++ to mark arguments as format strings to be able to do type checking). The type is specified in the string parameter and without additional metadata the compiler can’t do anything about that at compile time. The concept of spreading is safer than the Java implementation as there is a single parameter type instead of automatic vararg deduction. (Ever tried to have a single array be the variable argument of a vararg object in Java? You will have to do manual wrapping into a container array.)

2 Likes