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:
+12
@@ -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"
|
||||
}
|
||||
+14
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user