Files
kotlin-fork/compiler/testData/ir/irText/expressions/whenUnusedExpression.kt
T
Ting-Yuan Huang 1b4d26e490 psi2ir: keep the type of when when possible
Ideally, the type of `IrWhen` should be provided by type inference for
a consistent behavior. `USED_AS_EXPRESSION` from CFG isn't always
consistent with type inference, unfortunately.

The behavior is now aligned with `if`. The type of `when` is kept when
it *can* be an expression, instead of whether it is used or not.
2019-06-05 10:23:44 +02:00

10 lines
151 B
Kotlin
Vendored

// WITH_RUNTIME
fun test(b: Boolean, i: Int) {
if (b) {
when (i) {
0 -> 1
else -> null
}
} else null
}