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).
This commit is contained in:
Alexander Udalov
2023-06-28 15:12:10 +02:00
committed by Space Team
parent 5513740659
commit 79fa2b6db0
3 changed files with 10 additions and 11 deletions
@@ -24,7 +24,7 @@ fun testEmptyBranches2(flag: Boolean) {
else -> true
} /*~> Unit */
when {
flag -> true
flag -> true /*~> Unit */
else -> { // BLOCK
}
}
@@ -37,3 +37,4 @@ fun testEmptyBranches3(flag: Boolean) {
else -> true
} /*~> Unit */
}