Files
kotlin/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConst.kt
Dmitry Petrov a4c29b3587 Support Long and Char in const-bounded counter loop generation
If the loop end value is a compile-time constant (best we can do now),
and it is safe to iterate over a given range using "naive" for loop
(using '<=' or '>=' in loop condition),
generate such loops for Longs and Chars as well Ints (Bytes, Shorts).
2017-12-14 10:41:51 +03:00

12 lines
146 B
Kotlin
Vendored

const val N = 42
fun test(): Int {
var sum = 0
for (i in 1 .. N) {
sum += i
}
return sum
}
// 0 IF_ICMPEQ
// 1 IF_ICMPGT