Files
kotlin/compiler/testData/codegen/bytecodeText/nullCheckOptimization/ifUnitEqualsNullInline.kt
Dmitry Petrov 1378b0cf05 Fix bytecode tests after new optimizations
- Turn some const conditions into non-const conditions
- Make sure inlined const values are used where required
(otherwise they are eliminated by POP backward propagation)
2017-05-16 17:28:43 +03:00

18 lines
340 B
Kotlin
Vendored

// WITH_RUNTIME
// FILE: test.kt
fun test1(): String {
val u = Unit
return 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): R =
if (this == null) ifNull() else ifNotNull(this)