Fix for KT-14868: CCE in runtime while converting Number to Char
#KT-14868 Fixed
This commit is contained in:
@@ -405,11 +405,12 @@ public abstract class StackValue {
|
|||||||
coerce(unboxedType, toType, v);
|
coerce(unboxedType, toType, v);
|
||||||
}
|
}
|
||||||
else {
|
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);
|
coerce(fromType, boxType(toType), v);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
coerce(fromType, getType(Number.class), v);
|
coerce(fromType, numberType, v);
|
||||||
}
|
}
|
||||||
unbox(toType, 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
|
||||||
|
}
|
||||||
+6
@@ -10958,6 +10958,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("kt1508.kt")
|
||||||
public void testKt1508() throws Exception {
|
public void testKt1508() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
|
||||||
|
|||||||
@@ -10958,6 +10958,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("kt1508.kt")
|
||||||
public void testKt1508() throws Exception {
|
public void testKt1508() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
|
||||||
|
|||||||
@@ -10958,6 +10958,12 @@ public class LightAnalysisModeCodegenTestGenerated extends AbstractLightAnalysis
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("kt1508.kt")
|
||||||
public void testKt1508() throws Exception {
|
public void testKt1508() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
|
||||||
|
|||||||
@@ -12849,6 +12849,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("kt1508.kt")
|
||||||
public void testKt1508() throws Exception {
|
public void testKt1508() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/primitiveTypes/kt1508.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user