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 779fa79fad4..9596572b824 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 @@ -15993,6 +15993,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt"); } + @Test + @TestMetadata("kt53202.kt") + public void testKt53202() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt"); + } + + @Test + @TestMetadata("kt53202_funLiteral.kt") + public void testKt53202_funLiteral() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt"); + } + @Test @TestMetadata("nestedLambdas.kt") public void testNestedLambdas() throws Exception { diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ReturnableBlockLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ReturnableBlockLowering.kt index 5310b371319..c27d15b4e08 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ReturnableBlockLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ReturnableBlockLowering.kt @@ -127,7 +127,7 @@ class ReturnableBlockTransformer(val context: CommonBackendContext, val containe returnMap.remove(expression.symbol) if (!hasReturned) { - return IrCompositeImpl( + return IrBlockImpl( expression.startOffset, expression.endOffset, expression.type, diff --git a/compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt b/compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt new file mode 100644 index 00000000000..d706d850760 --- /dev/null +++ b/compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = "OK" + + val c = { + val b = a + b + }.invoke() + + return a +} diff --git a/compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt b/compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt new file mode 100644 index 00000000000..4a32e7f92e7 --- /dev/null +++ b/compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt @@ -0,0 +1,10 @@ +fun box(): String { + val a = "OK" + + val c = (fun(): String { + val b = a + return b + }).invoke() + + return a +} 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 90b0fe85dc4..a6baa73df3c 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 @@ -15807,6 +15807,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt"); } + @Test + @TestMetadata("kt53202.kt") + public void testKt53202() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt"); + } + + @Test + @TestMetadata("kt53202_funLiteral.kt") + public void testKt53202_funLiteral() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt"); + } + @Test @TestMetadata("nestedLambdas.kt") public void testNestedLambdas() 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 6ca561a4483..d13cb1aeed4 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 @@ -15993,6 +15993,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt"); } + @Test + @TestMetadata("kt53202.kt") + public void testKt53202() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt"); + } + + @Test + @TestMetadata("kt53202_funLiteral.kt") + public void testKt53202_funLiteral() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt"); + } + @Test @TestMetadata("nestedLambdas.kt") public void testNestedLambdas() 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 5e13eca1563..8be075934c3 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13020,6 +13020,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt"); } + @TestMetadata("kt53202.kt") + public void testKt53202() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt"); + } + + @TestMetadata("kt53202_funLiteral.kt") + public void testKt53202_funLiteral() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt"); + } + @TestMetadata("nestedLambdas.kt") public void testNestedLambdas() throws Exception { runTest("compiler/testData/codegen/box/directInvokeOptimization/nestedLambdas.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 0fb1513c59d..431856d7ebf 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -12197,6 +12197,18 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt"); } + @Test + @TestMetadata("kt53202.kt") + public void testKt53202() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt"); + } + + @Test + @TestMetadata("kt53202_funLiteral.kt") + public void testKt53202_funLiteral() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt"); + } + @Test @TestMetadata("nestedLambdas.kt") public void testNestedLambdas() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 340e0ec165e..b75ae0eeca1 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -12239,6 +12239,18 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt"); } + @Test + @TestMetadata("kt53202.kt") + public void testKt53202() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt"); + } + + @Test + @TestMetadata("kt53202_funLiteral.kt") + public void testKt53202_funLiteral() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt"); + } + @Test @TestMetadata("nestedLambdas.kt") public void testNestedLambdas() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 3dc6684121b..e324a049cbf 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -10870,6 +10870,16 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt"); } + @TestMetadata("kt53202.kt") + public void testKt53202() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt"); + } + + @TestMetadata("kt53202_funLiteral.kt") + public void testKt53202_funLiteral() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt"); + } + @TestMetadata("nestedLambdas.kt") public void testNestedLambdas() throws Exception { runTest("compiler/testData/codegen/box/directInvokeOptimization/nestedLambdas.kt"); diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 33820f915ac..60f4cf41d55 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -13243,6 +13243,18 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/directInvokeOptimization/contructorRef.kt"); } + @Test + @TestMetadata("kt53202.kt") + public void testKt53202() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202.kt"); + } + + @Test + @TestMetadata("kt53202_funLiteral.kt") + public void testKt53202_funLiteral() throws Exception { + runTest("compiler/testData/codegen/box/directInvokeOptimization/kt53202_funLiteral.kt"); + } + @Test @TestMetadata("nestedLambdas.kt") public void testNestedLambdas() throws Exception {