Files
kotlin-fork/compiler/testData/ir/irText/expressions/ifElseIf.fir.kt.txt
T
Alexander Udalov 79fa2b6db0 Fir2Ir: generate coercion to Unit for when branches if needed
Before this change, it could happen that `when` of type Unit has a
branch whose type is not Unit. This can lead to problems in IR
lowerings, for example PolymorphicSignatureLowering which is very
reliant on the correct types of expressions and placement of coercions
to Unit (KT-59218).
2023-07-18 11:37:41 +00:00

41 lines
593 B
Kotlin
Vendored

fun test(i: Int): Int {
return when {
greater(arg0 = i, arg1 = 0) -> 1
less(arg0 = i, arg1 = 0) -> -1
else -> 0
}
}
fun testEmptyBranches1(flag: Boolean) {
when {
flag -> { // BLOCK
}
else -> true
} /*~> Unit */
when {
flag -> true /*~> Unit */
}
}
fun testEmptyBranches2(flag: Boolean) {
when {
flag -> { // BLOCK
}
else -> true
} /*~> Unit */
when {
flag -> true /*~> Unit */
else -> { // BLOCK
}
}
}
fun testEmptyBranches3(flag: Boolean) {
when {
flag -> { // BLOCK
}
else -> true
} /*~> Unit */
}