mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
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
18 lines
378 B
Kotlin
Vendored
18 lines
378 B
Kotlin
Vendored
// WITH_RUNTIME
|
|
|
|
val arr = intArrayOf(10, 20, 30, 40)
|
|
|
|
fun foo(xs: Any): String {
|
|
if (xs !is IntArray) return "not an IntArray"
|
|
|
|
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'"
|
|
} |