Pop return value after implicit coercion to unit
This commit is contained in:
+4
-1
@@ -480,7 +480,10 @@ class IrInterpreter(irModule: IrModuleFragment) {
|
|||||||
|
|
||||||
private fun interpretTypeOperatorCall(expression: IrTypeOperatorCall, data: Frame): Code {
|
private fun interpretTypeOperatorCall(expression: IrTypeOperatorCall, data: Frame): Code {
|
||||||
return when (expression.operator) {
|
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 -> {
|
IrTypeOperator.CAST, IrTypeOperator.IMPLICIT_CAST -> {
|
||||||
val code = expression.argument.interpret(data)
|
val code = expression.argument.interpret(data)
|
||||||
if (!data.peekReturnValue().irClass.defaultType.isSubtypeOf(expression.type, irBuiltIns)) {
|
if (!data.peekReturnValue().irClass.defaultType.isSubtypeOf(expression.type, irBuiltIns)) {
|
||||||
|
|||||||
+9
@@ -35,7 +35,16 @@ interface State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setState(newVar: Variable)
|
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 copy(): State
|
||||||
|
|
||||||
fun getIrFunction(descriptor: FunctionDescriptor): IrFunction?
|
fun getIrFunction(descriptor: FunctionDescriptor): IrFunction?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user