Handle withIndex() on arrays and CharSequences in ForLoopsLowering.

This commit is contained in:
Mark Punzalan
2019-11-04 16:13:56 -08:00
committed by max-kammerer
parent 735535dd5a
commit a54d9482dd
25 changed files with 633 additions and 142 deletions
@@ -0,0 +1,15 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
val arr = arrayOf("a", "b", "c", "d")
fun box(): String {
var count = 0
for ((_, _) in arr.withIndex()) {
count++
}
return if (count == 4) "OK" else "fail: '$count'"
}
@@ -0,0 +1,17 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
val arr = arrayOf("a", "b", "c", "d")
fun box(): String {
val s = StringBuilder()
for (iv in arr.withIndex()) {
val (i, x) = iv
s.append("$i:$x;")
}
val ss = s.toString()
return if (ss == "0:a;1:b;2:c;3:d;") "OK" else "fail: '$ss'"
}