Files
kotlin/compiler/testData/codegen/box/controlStructures/forInArrayWithIndex/forInGenericArrayOfIntsWithIndexWithSmartCast.kt
Dmitry Petrov 99cea07bf4 Correctly map container element type in intrinsic for withIndex
In case of arrays, we couldn't distinguish array of boxed Ints
from array of primitive Ints.

 #KT-22904 Fixed Target versions 1.2.40
2018-02-20 09:18:25 +03:00

18 lines
375 B
Kotlin
Vendored

// WITH_RUNTIME
val arr = arrayOf(10, 20, 30, 40)
fun foo(xs: Any): String {
if (xs !is Array<*>) return "not an Array<*>"
val s = StringBuilder()
for ((index, x) in xs.withIndex()) {
s.append("$index:$x;")
}
return s.toString()
}
fun box(): String {
val ss = foo(arr)
return if (ss == "0:10;1:20;2:30;3:40;") "OK" else "fail: '$ss'"
}