Don't generate unnecessary checkcast to java.lang.Number
This commit is contained in:
@@ -396,9 +396,10 @@ public abstract class StackValue {
|
||||
}
|
||||
}
|
||||
else if (fromType.getSort() == Type.OBJECT) {
|
||||
if (fromType.equals(getType(Boolean.class)) || fromType.equals(getType(Character.class))) {
|
||||
unbox(unboxType(fromType), v);
|
||||
coerce(unboxType(fromType), toType, v);
|
||||
Type unboxedType = unboxPrimitiveTypeOrNull(fromType);
|
||||
if (unboxedType != null) {
|
||||
unbox(unboxedType, v);
|
||||
coerce(unboxedType, toType, v);
|
||||
}
|
||||
else {
|
||||
if (toType.getSort() == Type.BOOLEAN || toType.getSort() == Type.CHAR) {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fun test() {
|
||||
val z : Int? = 1
|
||||
val r = z!! + 1
|
||||
stubPreventBoxingOptimization(z)
|
||||
}
|
||||
|
||||
fun stubPreventBoxingOptimization(s: Int?) {
|
||||
s
|
||||
}
|
||||
|
||||
//0 CHECKCAST java/lang/Number
|
||||
@@ -263,6 +263,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noNumberCheckCast.kt")
|
||||
public void testNoNumberCheckCast() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/noNumberCheckCast.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noSuperCheckInDefaultConstuctor.kt")
|
||||
public void testNoSuperCheckInDefaultConstuctor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/noSuperCheckInDefaultConstuctor.kt");
|
||||
|
||||
Reference in New Issue
Block a user