When using vararg as indexed access operator argument, we can only use explicit get
function rather than square brackets. The following code shows this:
class A {
operator fun get(vararg index: Int): Int {
return 0
}
}
val a = A()
val b = a[1, 2, 3] // OK
val c = intArrayOf(1, 2, 3)
val d = a.get(*c) // OK
val e = a[c] //Error: Kotlin: Type mismatch: inferred type is IntArray but Int was expected
val f = a[*c]/*Error: Kotlin: None of the following functions can be called with the arguments supplied:
public final operator fun times(other: Byte): Int defined in kotlin.Int
public final operator fun times(other: Double): Double defined in kotlin.Int
public final operator fun times(other: Float): Float defined in kotlin.Int
public final operator fun times(other: Int): Int defined in kotlin.Int
public final operator fun times(other: Long): Long defined in kotlin.Int
public final operator fun times(other: Short): Int defined in kotlin.Int
*/
Is it a compiler bug?