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.
This commit is contained in:
committed by
TeamCityServer
parent
f62ffeaa0a
commit
d9e4dec810
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: STDLIB_GENERATED
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(xs: List<String>): String {
|
||||
var r = ""
|
||||
for ((i, x) in xs.withIndex()) {
|
||||
if (i > 1) break
|
||||
r += "$i:$x;"
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val t = test(listOf("a", "b", "c", "d", "e"))
|
||||
if (t != "0:a;1:b;") return "Failed: $t"
|
||||
return "OK"
|
||||
}
|
||||
compiler/testData/codegen/box/controlStructures/forInIterableWithIndex/forInListWithIndexContinue.kt
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: STDLIB_GENERATED
|
||||
// KJS_WITH_FULL_RUNTIME
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun test(xs: List<String>): String {
|
||||
var r = ""
|
||||
for ((i, x) in xs.withIndex()) {
|
||||
if (i % 2 == 0) continue
|
||||
r += "$i:$x;"
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val t = test(listOf("a", "b", "c", "d", "e"))
|
||||
if (t != "1:b;3:d;") return "Failed: $t"
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user