mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 00:21:28 +00:00
Make redundant null check optimization independent of boxing optimization algorithm.
Run DCE after each single redundant null check optimization pass.
This commit is contained in:
18
compiler/testData/codegen/bytecodeText/nullCheckOptimization/ifUnitEqualsNullInline.kt
vendored
Normal file
18
compiler/testData/codegen/bytecodeText/nullCheckOptimization/ifUnitEqualsNullInline.kt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test1() {
|
||||
val u = Unit
|
||||
u.mapNullable({ "X1" }, { "X2" })
|
||||
}
|
||||
|
||||
// @TestKt.class:
|
||||
// 0 IFNULL
|
||||
// 0 IFNONNULL
|
||||
// 1 X1
|
||||
// 0 X2
|
||||
|
||||
// FILE: inline.kt
|
||||
inline fun <T : Any, R> T?.mapNullable(ifNotNull: (T) -> R, ifNull: () -> R) =
|
||||
if (this == null) ifNull() else ifNotNull(this)
|
||||
Reference in New Issue
Block a user