JVM_IR: Block with nothing type do not generate values on the stack.
This commit is contained in:
+2
-3
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user