From 23ad0e7c6303ee70e4ccf5b249bed05471f6984d Mon Sep 17 00:00:00 2001 From: Roman Artemev Date: Thu, 28 Oct 2021 12:47:00 +0300 Subject: [PATCH] [TEST] Add test checking cast to DNN type muted temporary due to required support in backends --- .../FirBlackBoxCodegenTestGenerated.java | 6 ++++++ .../box/casts/castToDefinitelyNotNullType.kt | 17 +++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/IrBlackBoxCodegenTestGenerated.java | 6 ++++++ .../codegen/LightAnalysisModeTestGenerated.java | 5 +++++ .../IrJsCodegenBoxES6TestGenerated.java | 5 +++++ .../semantics/IrJsCodegenBoxTestGenerated.java | 5 +++++ .../IrCodegenBoxWasmTestGenerated.java | 5 +++++ .../js/testNew/JsCodegenBoxTestGenerated.java | 6 ++++++ 9 files changed, 61 insertions(+) create mode 100644 compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 0a6f293d706..ae88e4e73ae 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -4352,6 +4352,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/casts/castGenericNull.kt"); } + @Test + @TestMetadata("castToDefinitelyNotNullType.kt") + public void testCastToDefinitelyNotNullType() throws Exception { + runTest("compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt"); + } + @Test @TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt") public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception { diff --git a/compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt b/compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt new file mode 100644 index 00000000000..bf359a8eaa6 --- /dev/null +++ b/compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt @@ -0,0 +1,17 @@ +// !LANGUAGE: +DefinitelyNonNullableTypes +// IGNORE_BACKEND: JVM +// IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND: JS +// IGNORE_BACKEND: JS_IR +// IGNORE_BACKEND_FIR: JVM_IR + +fun test(t: T) = t as (T & Any) + +fun box(): String { + try { + test(null) + } catch (ex: NullPointerException) { + return "FAIL: expected NPE" + } + return test("OK") +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 075713a095e..d461bdea607 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -4280,6 +4280,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/casts/castGenericNull.kt"); } + @Test + @TestMetadata("castToDefinitelyNotNullType.kt") + public void testCastToDefinitelyNotNullType() throws Exception { + runTest("compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt"); + } + @Test @TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt") public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 63402b23a8c..549fbc6a74e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -4352,6 +4352,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/casts/castGenericNull.kt"); } + @Test + @TestMetadata("castToDefinitelyNotNullType.kt") + public void testCastToDefinitelyNotNullType() throws Exception { + runTest("compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt"); + } + @Test @TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt") public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 3af22b929be..45b2e7af29e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -3686,6 +3686,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class Casts extends AbstractLightAnalysisModeTest { + @TestMetadata("castToDefinitelyNotNullType.kt") + public void ignoreCastToDefinitelyNotNullType() throws Exception { + runTest("compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt"); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 0b275b4bd16..50d90d420a2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -2834,6 +2834,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/casts/castGenericNull.kt"); } + @TestMetadata("castToDefinitelyNotNullType.kt") + public void testCastToDefinitelyNotNullType() throws Exception { + runTest("compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt"); + } + @TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt") public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception { runTest("compiler/testData/codegen/box/casts/dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index e4364e7b322..59d5e1cad07 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -2834,6 +2834,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/casts/castGenericNull.kt"); } + @TestMetadata("castToDefinitelyNotNullType.kt") + public void testCastToDefinitelyNotNullType() throws Exception { + runTest("compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt"); + } + @TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt") public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception { runTest("compiler/testData/codegen/box/casts/dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 5ce373afe5d..09b122f8087 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -2824,6 +2824,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/casts/castGenericNull.kt"); } + @TestMetadata("castToDefinitelyNotNullType.kt") + public void testCastToDefinitelyNotNullType() throws Exception { + runTest("compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt"); + } + @TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt") public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception { runTest("compiler/testData/codegen/box/casts/dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testNew/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testNew/JsCodegenBoxTestGenerated.java index 053dd4d6b6e..4451daea8f8 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testNew/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testNew/JsCodegenBoxTestGenerated.java @@ -3152,6 +3152,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/casts/castGenericNull.kt"); } + @Test + @TestMetadata("castToDefinitelyNotNullType.kt") + public void testCastToDefinitelyNotNullType() throws Exception { + runTest("compiler/testData/codegen/box/casts/castToDefinitelyNotNullType.kt"); + } + @Test @TestMetadata("dontCreateInconsistentTypeDuringStarProjectionSubstitution.kt") public void testDontCreateInconsistentTypeDuringStarProjectionSubstitution() throws Exception {