From 5fdfd4a421eb845cf85393df26f3d4025fb4f6a8 Mon Sep 17 00:00:00 2001 From: Pavel Mikhailovskii Date: Mon, 10 Oct 2022 13:36:44 +0200 Subject: [PATCH] Revert "KT-53146 Don't coerce Nothing? returned from "catch" clauses" This reverts commit 903a5d69a40f0ec019413fd1e6dc2932751a87ab. --- .../FirBlackBoxCodegenTestGenerated.java | 6 ------ .../backend/jvm/codegen/ExpressionCodegen.kt | 4 +--- compiler/testData/codegen/box/casts/kt53146.kt | 18 ------------------ .../IrBlackBoxCodegenTestGenerated.java | 6 ------ 4 files changed, 1 insertion(+), 33 deletions(-) delete mode 100644 compiler/testData/codegen/box/casts/kt53146.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 d21690b5ffa..1e133bb6cca 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 @@ -4787,12 +4787,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/casts/kt50577.kt"); } - @Test - @TestMetadata("kt53146.kt") - public void testKt53146() throws Exception { - runTest("compiler/testData/codegen/box/casts/kt53146.kt"); - } - @Test @TestMetadata("kt53677.kt") public void testKt53677() throws Exception { diff --git a/compiler/ir/backend.jvm/codegen/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/codegen/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index cae3d0ae2b8..2f0df6457dc 100644 --- a/compiler/ir/backend.jvm/codegen/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/codegen/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -1225,9 +1225,7 @@ class ExpressionCodegen( val catchResult = catchBody.accept(this, catchBlockInfo) if (savedValue != null) { - if (catchResult.irType != context.irBuiltIns.nothingNType) { - catchResult.materializeAt(tryAsmType, aTry.type, true) - } + catchResult.materializeAt(tryAsmType, aTry.type, true) mv.store(savedValue, tryAsmType) } else { catchResult.discard() diff --git a/compiler/testData/codegen/box/casts/kt53146.kt b/compiler/testData/codegen/box/casts/kt53146.kt deleted file mode 100644 index 7c6b066c4fd..00000000000 --- a/compiler/testData/codegen/box/casts/kt53146.kt +++ /dev/null @@ -1,18 +0,0 @@ -// TARGET_BACKEND: JVM_IR -// WITH_STDLIB -// FULL_JDK -// CHECK_BYTECODE_TEXT - -class A - -fun box(): String { - val a = try { - A() - } catch (e: NoClassDefFoundError) { - null - } - - return "OK" -} - -// 0 CHECKCAST \ No newline at end of file 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 354a4323361..a5f0dd4ed2c 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 @@ -4787,12 +4787,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/casts/kt50577.kt"); } - @Test - @TestMetadata("kt53146.kt") - public void testKt53146() throws Exception { - runTest("compiler/testData/codegen/box/casts/kt53146.kt"); - } - @Test @TestMetadata("kt53677.kt") public void testKt53677() throws Exception {