Propagate KotlinType into when expression codegen

This commit removes unneeded boxing when result expression of `when` is
 value of inline class type
This commit is contained in:
Mikhail Zarechenskiy
2018-07-10 15:44:43 +03:00
parent 35b2b762cd
commit 8d24ca65a3
7 changed files with 46 additions and 2 deletions
@@ -4573,8 +4573,9 @@ The "returned" value of try expression with no finally is either the last expres
public StackValue generateWhenExpression(KtWhenExpression expression, boolean isStatement) {
Type resultType = isStatement ? Type.VOID_TYPE : expressionType(expression);
KotlinType resultKotlinType = isStatement ? null : kotlinType(expression);
return StackValue.operation(resultType, v -> {
return StackValue.operation(resultType, resultKotlinType, v -> {
KtProperty subjectVariable = expression.getSubjectVariable();
KtExpression subjectExpression = expression.getSubjectExpression();
@@ -4637,7 +4638,7 @@ The "returned" value of try expression with no finally is either the last expres
}
v.visitLabel(thisEntry);
gen(whenEntry.getExpression(), resultType);
gen(whenEntry.getExpression(), resultType, resultKotlinType);
mark.dropTo();
if (!whenEntry.isElse()) {
v.goTo(end);