d9e4dec810
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.
16 lines
297 B
Kotlin
Vendored
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"
|
|
} |