Pop return value after implicit coercion to unit

This commit is contained in:
Ivan Kylchik
2020-01-30 13:45:15 +03:00
parent 792ae8d272
commit d03937cdb6
2 changed files with 13 additions and 1 deletions
@@ -480,7 +480,10 @@ class IrInterpreter(irModule: IrModuleFragment) {
private fun interpretTypeOperatorCall(expression: IrTypeOperatorCall, data: Frame): Code {
return when (expression.operator) {
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> expression.argument.interpret(data)
IrTypeOperator.IMPLICIT_COERCION_TO_UNIT -> {
// coercion to unit means that return value isn't used
expression.argument.interpret(data).apply { if (this == Code.NEXT) data.popReturnValue() }
}
IrTypeOperator.CAST, IrTypeOperator.IMPLICIT_CAST -> {
val code = expression.argument.interpret(data)
if (!data.peekReturnValue().irClass.defaultType.isSubtypeOf(expression.type, irBuiltIns)) {
@@ -35,7 +35,16 @@ interface State {
}
fun setState(newVar: Variable)
/**
* This method is used for passing a copy of a state.
* It is necessary then copy change its state's value, but the original one must remain the same.
*
* @see copyReceivedValue.kt
* @see tryFinally.kt
*/
fun copy(): State
fun getIrFunction(descriptor: FunctionDescriptor): IrFunction?
}