diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt index f52c4cba9a4..8806c6cad2c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/BinaryOp.kt @@ -34,7 +34,7 @@ public class BinaryOp(private val opcode: Int) : IntrinsicMethod() { val operandType = numberFunctionOperandType(returnType) val paramType = if (shift()) Type.INT_TYPE else operandType - return createBinaryIntrinsicCallable(operandType, paramType, operandType) { + return createBinaryIntrinsicCallable(returnType, paramType, operandType) { v -> v.visitInsn(returnType.getOpcode(opcode)) } } diff --git a/compiler/testData/codegen/box/binaryOp/callAny.kt b/compiler/testData/codegen/box/binaryOp/callAny.kt new file mode 100644 index 00000000000..7969cb5ec79 --- /dev/null +++ b/compiler/testData/codegen/box/binaryOp/callAny.kt @@ -0,0 +1,21 @@ +fun box(): String { + val a1: Any = 1.toByte().plus(1) + val a2: Any = 1.toShort().plus(1) + val a3: Any = 1.plus(1) + val a4: Any = 1L.plus(1) + val a5: Any = 1.0.plus(1) + val a6: Any = 1f.plus(1) + val a7: Any = 'A'.plus(1) + val a8: Any = 'B'.minus('A') + + if (a1 !is Int || a1 != 2) return "fail 1" + if (a2 !is Int || a2 != 2) return "fail 2" + if (a3 !is Int || a3 != 2) return "fail 3" + if (a4 !is Long || a4 != 2L) return "fail 4" + if (a5 !is Double || a5 != 2.0) return "fail 5" + if (a6 !is Float || a6 != 2f) return "fail 6" + if (a7 !is Char || a7 != 'B') return "fail 7" + if (a8 !is Int || a8 != 1) return "fail 8" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/binaryOp/infixCallAny.kt b/compiler/testData/codegen/box/binaryOp/infixCallAny.kt new file mode 100644 index 00000000000..6056e74e00e --- /dev/null +++ b/compiler/testData/codegen/box/binaryOp/infixCallAny.kt @@ -0,0 +1,21 @@ +fun box(): String { + val a1: Any = 1.toByte() plus 1 + val a2: Any = 1.toShort() plus 1 + val a3: Any = 1 plus 1 + val a4: Any = 1L plus 1 + val a5: Any = 1.0 plus 1 + val a6: Any = 1f plus 1 + val a7: Any = 'A' plus 1 + val a8: Any = 'B' minus 'A' + + if (a1 !is Int || a1 != 2) return "fail 1" + if (a2 !is Int || a2 != 2) return "fail 2" + if (a3 !is Int || a3 != 2) return "fail 3" + if (a4 !is Long || a4 != 2L) return "fail 4" + if (a5 !is Double || a5 != 2.0) return "fail 5" + if (a6 !is Float || a6 != 2f) return "fail 6" + if (a7 !is Char || a7 != 'B') return "fail 7" + if (a8 !is Int || a8 != 1) return "fail 8" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/binaryOp/intrinsicAny.kt b/compiler/testData/codegen/box/binaryOp/intrinsicAny.kt new file mode 100644 index 00000000000..fd240b08a58 --- /dev/null +++ b/compiler/testData/codegen/box/binaryOp/intrinsicAny.kt @@ -0,0 +1,21 @@ +fun box(): String { + val a1: Any = 1.toByte() + 1 + val a2: Any = 1.toShort() + 1 + val a3: Any = 1 + 1 + val a4: Any = 1L + 1 + val a5: Any = 1.0 + 1 + val a6: Any = 1f + 1 + val a7: Any = 'A' + 1 + val a8: Any = 'B' - 'A' + + if (a1 !is Int || a1 != 2) return "fail 1" + if (a2 !is Int || a2 != 2) return "fail 2" + if (a3 !is Int || a3 != 2) return "fail 3" + if (a4 !is Long || a4 != 2L) return "fail 4" + if (a5 !is Double || a5 != 2.0) return "fail 5" + if (a6 !is Float || a6 != 2f) return "fail 6" + if (a7 !is Char || a7 != 'B') return "fail 7" + if (a8 !is Int || a8 != 1) return "fail 8" + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index f1b138005b2..357a6e933b2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -262,6 +262,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("callAny.kt") + public void testCallAny() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/callAny.kt"); + doTest(fileName); + } + @TestMetadata("callNullable.kt") public void testCallNullable() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/callNullable.kt"); @@ -280,6 +286,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("infixCallAny.kt") + public void testInfixCallAny() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/infixCallAny.kt"); + doTest(fileName); + } + @TestMetadata("infixCallNullable.kt") public void testInfixCallNullable() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/infixCallNullable.kt"); @@ -292,6 +304,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("intrinsicAny.kt") + public void testIntrinsicAny() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/intrinsicAny.kt"); + doTest(fileName); + } + @TestMetadata("intrinsicNullable.kt") public void testIntrinsicNullable() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/binaryOp/intrinsicNullable.kt");