Use correctElementType to determine array element type for withIndex

Rather unkind "gotcha" in ASM API.

 #KT-23900 Fixed Target versions 1.2.50
This commit is contained in:
Dmitry Petrov
2018-04-23 11:37:52 +03:00
parent 5817a7fdac
commit 1eca402332
8 changed files with 73 additions and 11 deletions
@@ -0,0 +1,12 @@
// WITH_RUNTIME
fun box(): String {
val arr = Array(4) { arrayOf("x$it") }
var s = ""
for ((i, sarr) in arr.withIndex()) {
s += "$i:${sarr.toList()}"
}
return if (s != "0:[x0]1:[x1]2:[x2]3:[x3]") "Fail: '$s'" else "OK"
}
@@ -0,0 +1,14 @@
// WITH_RUNTIME
fun box(): String {
// [[0], [1], [2], [3]]
val arr = Array(4) { intArrayOf(it) }
var s = 0
for ((i, iarr) in arr.withIndex()) {
s += i*iarr[0]
}
// 0 + 1 + 4 + 9 = 14
return if (s != 14) "Fail: $s" else "OK"
}