JVM_IR: Block with nothing type do not generate values on the stack.

This commit is contained in:
Mads Ager
2019-02-07 15:19:08 +01:00
committed by max-kammerer
parent b37aeb8f14
commit b902da55d5
3 changed files with 2 additions and 5 deletions
@@ -243,13 +243,12 @@ class ExpressionCodegen(
}
override fun visitContainerExpression(expression: IrContainerExpression, data: BlockInfo): StackValue {
// Empty blocks with nothing type should not generate a value on the stack. They
// arise for if statements with missing branches such as: if (expr) else 42
if (expression.statements.size == 0 && expression.type.isNothing()) return none()
val result = expression.statements.fold(none()) { _, exp ->
//coerceNotToUnit(r.type, Type.VOID_TYPE)
exp.accept(this, data)
}
// Blocks with nothing type do not generate a value on the stack.
if (expression.type.isNothing()) return none()
return coerceNotToUnit(result.type, result.kotlinType, expression.type.toKotlinType())
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND: JS_IR
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// TARGET_BACKEND: JVM
// WITH_RUNTIME