Files
kotlin-fork/compiler/testData/codegen/box/ranges/capturedLoopVar.kt
T
Dmitry Petrov d9e4dec810 JVM_IR reuse loop variable as index variable should happen after LDL
We can't apply "reuse loop variable as index variable" transformation
before local declarations lowering, otherwise it will affect captured
loop variable behavior, resulting in KT-48626.

Since it's JVM-specific, move it to JvmOptimizationLowering.
2021-09-06 22:16:40 +03:00

16 lines
297 B
Kotlin
Vendored

// IGNORE_BACKEND: WASM
// WITH_RUNTIME
fun build(): List<() -> Int> {
val r = ArrayList<() -> Int>()
for (i in 0 until 3) {
r.add({ i })
}
return r
}
fun box(): String {
val t = build().map { it() }
if (t != listOf(0, 1, 2)) return "Failed: $t"
return "OK"
}