Ensure value of correct return type is on stack after intrinsic Char +/- Int and Char - Char binary operations.

This commit is contained in:
Ilya Gorbunov
2015-07-05 03:15:29 +03:00
parent 222d4002ac
commit 456bab40d1
5 changed files with 82 additions and 1 deletions
@@ -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))
}
}
+21
View File
@@ -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"
}
+21
View File
@@ -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"
}
+21
View File
@@ -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"
}
@@ -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");