Dead code elimination

#KT-6602 Fixed
 #KT-6305 Fixed
 #KT-5656 Fixed
This commit is contained in:
Denis Zharkov
2014-12-30 14:55:45 +03:00
parent aecb925b7b
commit 5675d2b26b
10 changed files with 218 additions and 10 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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