KT-12985 Do not create range instances for 'for' loop in CharSequence.indices

This commit is contained in:
Dmitry Petrov
2016-07-05 16:06:18 +03:00
parent 3dc23a0e02
commit 3445fe0d30
6 changed files with 71 additions and 1 deletions
@@ -0,0 +1,16 @@
// WITH_RUNTIME
fun test(s: CharSequence): Int {
var result = 0
for (i in s.indices) {
result = result * 10 + (i + 1)
}
return result
}
fun box(): String {
val test = test("abcd")
if (test != 1234) return "Fail: $test"
return "OK"
}