6d9f02cfc6
For code such as:
```
try {
var y = "y"
for (i in 0 until 1) {
return y
}
} finally {
println("finally")
}
```
The local variables `y` and `i` ended up covering the finally block as
well in the debugger.
This change splits the range of the locals so that they do
not cover the finally block.
This change does not change the inliner to do similar transformations,
so the range of locals is still wrong win finally blocks when inlined
into an inline function. Added a failing test to that effect.
39 lines
1.5 KiB
Kotlin
Vendored
39 lines
1.5 KiB
Kotlin
Vendored
// FILE: test.kt
|
|
|
|
fun compute(): String {
|
|
var result = ""
|
|
for (x in listOf("A", "B")) {
|
|
try {
|
|
val y = "y"
|
|
result += y
|
|
return result
|
|
}
|
|
finally {
|
|
val z = "z"
|
|
result += z
|
|
}
|
|
}
|
|
return result
|
|
}
|
|
|
|
fun box() {
|
|
compute()
|
|
}
|
|
|
|
// The old backend has the local y covering the finally block as well.
|
|
// IGNORE_BACKEND: JVM
|
|
|
|
// LOCAL VARIABLES
|
|
// test.kt:20 box:
|
|
// test.kt:4 compute:
|
|
// test.kt:5 compute: result:java.lang.String="":java.lang.String
|
|
// test.kt:6 compute: result:java.lang.String="":java.lang.String, x:java.lang.String="A":java.lang.String
|
|
// test.kt:7 compute: result:java.lang.String="":java.lang.String, x:java.lang.String="A":java.lang.String
|
|
// test.kt:8 compute: result:java.lang.String="":java.lang.String, x:java.lang.String="A":java.lang.String, y:java.lang.String="y":java.lang.String
|
|
// test.kt:9 compute: result:java.lang.String="y":java.lang.String, x:java.lang.String="A":java.lang.String, y:java.lang.String="y":java.lang.String
|
|
// test.kt:12 compute: result:java.lang.String="y":java.lang.String, x:java.lang.String="A":java.lang.String
|
|
// test.kt:13 compute: result:java.lang.String="y":java.lang.String, x:java.lang.String="A":java.lang.String, z:java.lang.String="z":java.lang.String
|
|
// test.kt:9 compute: result:java.lang.String="yz":java.lang.String, x:java.lang.String="A":java.lang.String, y:java.lang.String="y":java.lang.String
|
|
// test.kt:20 box:
|
|
// test.kt:21 box:
|