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.
This commit is contained in:
Ting-Yuan Huang
2019-05-23 10:28:09 -07:00
committed by max-kammerer
parent cd651be461
commit 1b4d26e490
7 changed files with 69 additions and 8 deletions
@@ -1267,6 +1267,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
runTest("compiler/testData/ir/irText/expressions/whenReturn.kt");
}
@TestMetadata("whenUnusedExpression.kt")
public void testWhenUnusedExpression() throws Exception {
runTest("compiler/testData/ir/irText/expressions/whenUnusedExpression.kt");
}
@TestMetadata("whenWithSubjectVariable.kt")
public void testWhenWithSubjectVariable() throws Exception {
runTest("compiler/testData/ir/irText/expressions/whenWithSubjectVariable.kt");