79fa2b6db0
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).
41 lines
593 B
Kotlin
Vendored
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 */
|
|
}
|
|
|