Fix for KT-14868: CCE in runtime while converting Number to Char

#KT-14868 Fixed
This commit is contained in:
Mikhael Bogdanov
2016-12-20 10:38:23 +01:00
parent ce333b0a58
commit ef825a7559
7 changed files with 36 additions and 2 deletions
@@ -405,11 +405,12 @@ public abstract class StackValue {
coerce(unboxedType, toType, v);
}
else {
if (toType.getSort() == Type.BOOLEAN || toType.getSort() == Type.CHAR) {
Type numberType = getType(Number.class);
if (toType.getSort() == Type.BOOLEAN || (toType.getSort() == Type.CHAR && !numberType.equals(fromType))) {
coerce(fromType, boxType(toType), v);
}
else {
coerce(fromType, getType(Number.class), v);
coerce(fromType, numberType, v);
}
unbox(toType, v);
}
@@ -0,0 +1,6 @@
fun box(): String {
val x: Number = 75
return "O" + x.toChar()
}
@@ -0,0 +1,3 @@
public final class Kt14868Kt {
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
}
@@ -10958,6 +10958,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("kt14868.kt")
public void testKt14868() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt14868.kt");
doTest(fileName);
}
@TestMetadata("kt1508.kt")
public void testKt1508() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
@@ -10958,6 +10958,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("kt14868.kt")
public void testKt14868() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt14868.kt");
doTest(fileName);
}
@TestMetadata("kt1508.kt")
public void testKt1508() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
@@ -10958,6 +10958,12 @@ public class LightAnalysisModeCodegenTestGenerated extends AbstractLightAnalysis
doTest(fileName);
}
@TestMetadata("kt14868.kt")
public void testKt14868() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt14868.kt");
doTest(fileName);
}
@TestMetadata("kt1508.kt")
public void testKt1508() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
@@ -12849,6 +12849,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTest(fileName);
}
@TestMetadata("kt14868.kt")
public void testKt14868() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt14868.kt");
doTest(fileName);
}
@TestMetadata("kt1508.kt")
public void testKt1508() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");