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)'.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
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"
|
||||
}
|
||||
Reference in New Issue
Block a user