mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
Dead code elimination
#KT-6602 Fixed #KT-6305 Fixed #KT-5656 Fixed
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
fun foo(x: Any?) {}
|
||||
|
||||
fun box() {
|
||||
val x: Int? = 1
|
||||
x!!
|
||||
|
||||
val z: Int? = if (1 == 1) x else null
|
||||
z!!
|
||||
|
||||
foo(1 as java.lang.Integer)
|
||||
}
|
||||
|
||||
// 0 IFNULL
|
||||
// 1 IFNONNULL
|
||||
// 1 throwNpe
|
||||
// 0 ATHROW
|
||||
@@ -0,0 +1,7 @@
|
||||
fun foo() {
|
||||
return
|
||||
// val xyz has empty live range because everything after return will be removed as dead
|
||||
val xyz = 1
|
||||
}
|
||||
|
||||
// 0 xyz
|
||||
@@ -0,0 +1,23 @@
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun foo(value: Boolean): Int {
|
||||
if (value)
|
||||
return 1
|
||||
else
|
||||
return 2
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(1, foo(true))
|
||||
assertEquals(2, foo(false))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
/*
|
||||
3 return's are defined in functions
|
||||
2 are from package facade
|
||||
1 is from package clinit
|
||||
*/
|
||||
|
||||
// 6 RETURN
|
||||
Reference in New Issue
Block a user