Files
kotlin/compiler/testData/codegen/bytecodeText/nullCheckOptimization/ifUnitEqualsNullInline.kt
Dmitry Petrov 3fc106572e Make redundant null check optimization independent of boxing optimization algorithm.
Run DCE after each single redundant null check optimization pass.
2017-03-13 09:04:31 +03:00

18 lines
322 B
Kotlin
Vendored

// 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)