diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.kt index 2524643485b..cb83708349d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/OptimizationMethodVisitor.kt @@ -66,6 +66,8 @@ class OptimizationMethodVisitor( optimizationTransformer.transform("fake", methodNode) } + DeadCodeEliminationMethodTransformer().transform("fake", methodNode) + methodNode.prepareForEmitting() } diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt new file mode 100644 index 00000000000..5318e79ce96 --- /dev/null +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt @@ -0,0 +1,35 @@ +// IGNORE_BACKEND: JVM_IR +// NO_CHECK_LAMBDA_INLINING +// FILE: 1.kt + +package test + +inline fun takeWhileSize(initialSize: Int , block: (String) -> Int) { + val current = "PARAM" + + try { + if (1 >= initialSize) { + try { + block(current) + } finally { + val i = "INNER FINALLY" + } + } else { + val e = "ELSE" + } + } finally { + val o = "OUTER FINALLY" + } +} + +// FILE: 2.kt +import test.* + + +fun box(): String { + takeWhileSize(1) { + return "OK" + } + + return "fail" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 76133edb41f..76fbb64d72e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -2060,6 +2060,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt"); } + @TestMetadata("kt28546.kt") + public void testKt28546() throws Exception { + runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt"); + } + @TestMetadata("kt6956.kt") public void testKt6956() throws Exception { runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 2b78cff1ea8..a40bb1dfb5e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -2060,6 +2060,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt"); } + @TestMetadata("kt28546.kt") + public void testKt28546() throws Exception { + runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt"); + } + @TestMetadata("kt6956.kt") public void testKt6956() throws Exception { runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 7973e3909e3..e3f4ba18b87 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -2060,6 +2060,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt"); } + @TestMetadata("kt28546.kt") + public void testKt28546() throws Exception { + runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt"); + } + @TestMetadata("kt6956.kt") public void testKt6956() throws Exception { runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrNonLocalReturnsTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrNonLocalReturnsTestGenerated.java index 26c5ec5661c..bed4063f509 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrNonLocalReturnsTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrNonLocalReturnsTestGenerated.java @@ -164,6 +164,11 @@ public class IrNonLocalReturnsTestGenerated extends AbstractIrNonLocalReturnsTes runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt"); } + @TestMetadata("kt28546.kt") + public void testKt28546() throws Exception { + runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt"); + } + @TestMetadata("kt6956.kt") public void testKt6956() throws Exception { runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/NonLocalReturnsTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/NonLocalReturnsTestGenerated.java index 9321824d1d3..3815681ae9c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/NonLocalReturnsTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/NonLocalReturnsTestGenerated.java @@ -164,6 +164,11 @@ public class NonLocalReturnsTestGenerated extends AbstractNonLocalReturnsTest { runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt26384_2.kt"); } + @TestMetadata("kt28546.kt") + public void testKt28546() throws Exception { + runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt28546.kt"); + } + @TestMetadata("kt6956.kt") public void testKt6956() throws Exception { runTest("compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt6956.kt");