ForLoopsLowering: Handle Iterable.withIndex() where the type is a

bounded type parameter.

TODO: Handle Sequences by extending DefaultIterableHandler.
This commit is contained in:
Mark Punzalan
2019-11-26 23:19:00 -08:00
committed by max-kammerer
parent e8252ea874
commit 1a2e09e6a5
20 changed files with 231 additions and 12 deletions
@@ -0,0 +1,20 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
val xs = listOf("a", "b", "c", "d")
fun <T : Iterable<*>> test(iterable: T): String {
val s = StringBuilder()
for ((index, x) in iterable.withIndex()) {
s.append("$index:$x;")
}
return s.toString()
}
fun box(): String {
val ss = test(xs)
return if (ss == "0:a;1:b;2:c;3:d;") "OK" else "fail: '$ss'"
}