Ensure type of a stack value is coerced to the expected return type after the binary operation instruction with the different return type.
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen.intrinsics
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.numberFunctionOperandType
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.ISHL
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.ISHR
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.IUSHR
|
||||
@@ -35,7 +36,10 @@ public class BinaryOp(private val opcode: Int) : IntrinsicMethod() {
|
||||
val paramType = if (shift()) Type.INT_TYPE else operandType
|
||||
|
||||
return createBinaryIntrinsicCallable(returnType, paramType, operandType) {
|
||||
v -> v.visitInsn(returnType.getOpcode(opcode))
|
||||
v ->
|
||||
v.visitInsn(returnType.getOpcode(opcode));
|
||||
if (operandType != returnType)
|
||||
StackValue.coerce(operandType, returnType, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user