Fix KNPE caused by optimizations in control-flow analysis
The problem is that when performing full analysis we do it in a backward order while result for trivial vals is filled in a forward one. It turns out that reversedInstuctions might return a superset of forward traversed instructions, e.g. in case of dead code in lambda. At the same time result for trivial vals is constant for any instruction, thus we can just return its constant value and use it in the full analysis #KT-20895 Fixed
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
|
||||
inline fun myRun(b: () -> Unit) = b()
|
||||
|
||||
fun foo() {
|
||||
var <!UNUSED_VARIABLE!>a<!>: Int
|
||||
return
|
||||
|
||||
<!UNREACHABLE_CODE!>myRun {
|
||||
return
|
||||
}<!>
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun foo(): kotlin.Unit
|
||||
public inline fun myRun(/*0*/ b: () -> kotlin.Unit): kotlin.Unit
|
||||
Reference in New Issue
Block a user