Files
kotlin/compiler/testData/codegen/box/ranges/forInRangeToConstWithOverflow.kt
Dmitry Petrov b867c46f72 Generate for-in-range loop as counter loop when possible
If an upper bound is a compile-time constant != Int.MAX_VALUE,
we can generate 'for (i in x..N)' as 'for (i in x until N+1)'.
2017-07-27 09:02:26 +03:00

12 lines
266 B
Kotlin
Vendored

const val M = Int.MAX_VALUE
fun box(): String {
var step = 0
for (i in M .. M) {
++step
if (step > 1) throw AssertionError("Should be executed once")
}
if (step != 1) throw AssertionError("Should be executed once")
return "OK"
}