JVM_IR fix cast to non-null primitive type (FIR bootstrap issue)

This commit is contained in:
Dmitry Petrov
2022-01-13 11:03:18 +03:00
committed by Space
parent 2ba0a7b40f
commit d184babda6
11 changed files with 111 additions and 1 deletions
@@ -18313,6 +18313,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo1.kt")
public void testAnyCastToPrimitiveCompareTo1() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo1.kt");
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo2.kt")
public void testAnyCastToPrimitiveCompareTo2() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo2.kt");
}
@Test
@TestMetadata("anyToReal.kt")
public void testAnyToReal() throws Exception {
@@ -99,7 +99,7 @@ private class TypeOperatorLowering(private val backendContext: JvmBackendContext
// We have to generate a null check here, because even if argument is of non-null type,
// it can be uninitialized value, which is 'null' for reference types in JMM.
// Most of such null checks will never actually throw, but we can't do anything about it.
irBlock {
irBlock(resultType = type) {
+irCall(backendContext.ir.symbols.checkNotNullWithMessage).apply {
putValueArgument(0, irGet(tmp.owner))
putValueArgument(1, message)
@@ -0,0 +1,9 @@
class C(val value: Any)
fun box(): String {
val c1 = C(-0.0)
val c2 = C(0.toByte())
val cmp = (c1.value as Double).compareTo(c2.value as Byte)
if (cmp != -1) return "Failed: cmp=$cmp"
return "OK"
}
@@ -0,0 +1,9 @@
class C(val value: Any)
fun box(): String {
val c1 = C(1.1)
val c2 = C(1)
val cmp = (c1.value as Double).compareTo(c2.value as Int)
if (cmp != 1) return "Failed: cmp=$cmp"
return "OK"
}
@@ -17917,6 +17917,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo1.kt")
public void testAnyCastToPrimitiveCompareTo1() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo1.kt");
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo2.kt")
public void testAnyCastToPrimitiveCompareTo2() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo2.kt");
}
@Test
@TestMetadata("anyToReal.kt")
public void testAnyToReal() throws Exception {
@@ -18313,6 +18313,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo1.kt")
public void testAnyCastToPrimitiveCompareTo1() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo1.kt");
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo2.kt")
public void testAnyCastToPrimitiveCompareTo2() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo2.kt");
}
@Test
@TestMetadata("anyToReal.kt")
public void testAnyToReal() throws Exception {
@@ -14873,6 +14873,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
}
@TestMetadata("anyCastToPrimitiveCompareTo1.kt")
public void testAnyCastToPrimitiveCompareTo1() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo1.kt");
}
@TestMetadata("anyCastToPrimitiveCompareTo2.kt")
public void testAnyCastToPrimitiveCompareTo2() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo2.kt");
}
@TestMetadata("anyToReal.kt")
public void testAnyToReal() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyToReal.kt");
@@ -13941,6 +13941,18 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo1.kt")
public void testAnyCastToPrimitiveCompareTo1() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo1.kt");
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo2.kt")
public void testAnyCastToPrimitiveCompareTo2() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo2.kt");
}
@Test
@TestMetadata("anyToReal.kt")
public void testAnyToReal() throws Exception {
@@ -13983,6 +13983,18 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo1.kt")
public void testAnyCastToPrimitiveCompareTo1() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo1.kt");
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo2.kt")
public void testAnyCastToPrimitiveCompareTo2() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo2.kt");
}
@Test
@TestMetadata("anyToReal.kt")
public void testAnyToReal() throws Exception {
@@ -11710,6 +11710,16 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ieee754"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
}
@TestMetadata("anyCastToPrimitiveCompareTo1.kt")
public void testAnyCastToPrimitiveCompareTo1() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo1.kt");
}
@TestMetadata("anyCastToPrimitiveCompareTo2.kt")
public void testAnyCastToPrimitiveCompareTo2() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo2.kt");
}
@TestMetadata("anyToReal.kt")
public void testAnyToReal() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyToReal.kt");
@@ -14971,6 +14971,18 @@ public class ExternalTestGenerated extends AbstractExternalNativeBlackBoxTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ieee754"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo1.kt")
public void testAnyCastToPrimitiveCompareTo1() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo1.kt");
}
@Test
@TestMetadata("anyCastToPrimitiveCompareTo2.kt")
public void testAnyCastToPrimitiveCompareTo2() throws Exception {
runTest("compiler/testData/codegen/box/ieee754/anyCastToPrimitiveCompareTo2.kt");
}
@Test
@TestMetadata("anyToReal.kt")
public void testAnyToReal() throws Exception {