mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
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).
12 lines
266 B
Kotlin
Vendored
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"
|
|
} |