[JVM] Do not extend local ranges across control-flow merges.
The coroutine method transformer extends the range of locals across code where the local is not live when it is safe to do so. However, it only bailed out for one case of control-flow merging, namely backwards branches for loops. That is not sufficient as there can be control flow merges without loops where the local is only defined on one control-flow path. This change generalizes the bailout to any control-flow merge. ^KT-49834 Fixed
This commit is contained in:
committed by
Alexander Udalov
parent
8ace9e45b9
commit
8255118204
@@ -0,0 +1,18 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
fun getValue() : String? = null
|
||||
suspend fun computeValue() = "O"
|
||||
|
||||
suspend fun repro() : String {
|
||||
val value = getValue()
|
||||
return if (value == null) {
|
||||
computeValue()
|
||||
} else {
|
||||
value
|
||||
} + "K"
|
||||
}
|
||||
|
||||
// This test is checking that the local variable table for `repro` is valid.
|
||||
// This is checked because the D8 dexer is run on the produced code and
|
||||
// we fail the tests on warnings because of invalid locals.
|
||||
fun box() = "OK"
|
||||
Reference in New Issue
Block a user