diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java index 3f8dad6713c..b8ee304a3d6 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java @@ -56,6 +56,12 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenTestGenerated.java index 97b52ae65f9..7d3aac7f1b8 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenTestGenerated.java @@ -56,6 +56,12 @@ public class FirLightTreeBlackBoxInlineCodegenTestGenerated extends AbstractFirL KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java index 3f02c900db0..fb61c72a737 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -56,6 +56,12 @@ public class FirSerializeCompileKotlinAgainstInlineKotlinTestGenerated extends A KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR_SERIALIZE, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt b/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt new file mode 100644 index 00000000000..3964167098f --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt @@ -0,0 +1,91 @@ +// IGNORE_BACKEND: WASM +// NO_CHECK_LAMBDA_INLINING + +// FILE: utils.kt +fun functionWithLambda(f: (String) -> String): String = f("OK") + +fun functionWithLambda(f: (StringWrapper) -> StringWrapper): StringWrapper = f(StringWrapper("OK")) + +fun genericFunctionWithLambda(f: () -> T): T = f() + +inline fun T.testLet(block: (T) -> R): R = block(this) + +inline fun T.testApplyToExtensionReceiver(block: T.() -> Unit): T { + block() + return this +} + +class StringWrapper(val s: String) { + inline fun testApplyToDispatchReceiver(block: StringWrapper.() -> Unit): String { + block() + return s + } +} + +inline fun testApplyToArg0(args: T, block: T.() -> Unit): T { + args.block() + return args +} + +// FILE: testClass.kt +class TestClass { + val testExtensionReceiver = functionWithLambda { strArg: String -> + val anonymousObj = genericFunctionWithLambda { + strArg.testLet { + object { + val strField = it + } + } + } + anonymousObj.strField + }.testApplyToExtensionReceiver {} + + val testDispatchReceiver = functionWithLambda { strArg: StringWrapper -> + val anonymousObj = genericFunctionWithLambda { + strArg.testLet { + object { + val strField = it + } + } + } + anonymousObj.strField + }.testApplyToDispatchReceiver {} + + val testArg0 = testApplyToArg0(functionWithLambda { strArg: String -> + val anonymousObj = genericFunctionWithLambda { + strArg.testLet { + object { + val strField = it + } + } + } + anonymousObj.strField + }) {} + + val testChain = functionWithLambda { strArg: String -> + val anonymousObj = genericFunctionWithLambda { + strArg.testLet { + object { + val strField1 = it + } + }.testLet { + object { + val strField2 = it.strField1 + } + } + } + anonymousObj.strField2 + }.testApplyToExtensionReceiver {} +} + +// FILE: main.kt +fun box(): String { + val testObject = TestClass() + when { + testObject.testExtensionReceiver != "OK" -> return "testExtensionReceiver failed" + testObject.testDispatchReceiver != "OK" -> return "testDispatchReceiver failed" + testObject.testArg0 != "OK" -> return "testArg0 failed" + testObject.testChain != "OK" -> return "testChain failed" + else -> return "OK" + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java index f0764d10d5a..cbd91decf34 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -56,6 +56,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 332f9f77198..b8eed14f519 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -56,6 +56,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java index 52beff031af..89c02d5fe12 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java @@ -56,6 +56,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index b4e4de73685..4f774d71cb9 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -56,6 +56,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java index c73c5bc90bc..3a4dca59acf 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -56,6 +56,12 @@ public class IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated extends Ab KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java index 37dda60f713..6b7cc905d63 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -56,6 +56,12 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_IR_AGAINST_OLD, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java index b562d5b1995..e0995a1fdf8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -56,6 +56,12 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_OLD_AGAINST_IR, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenInlineTestGenerated.java index 4e6b11f3a4a..b23cba2f5b3 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenInlineTestGenerated.java @@ -56,6 +56,12 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenInlineTestGenerated.java index d8c309206f5..7844fa774ce 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenInlineTestGenerated.java @@ -56,6 +56,12 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxInlineWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxInlineWasmTestGenerated.java index 97f03537498..5e4ff8a7423 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxInlineWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxInlineWasmTestGenerated.java @@ -65,6 +65,11 @@ public class IrCodegenBoxInlineWasmTestGenerated extends AbstractIrCodegenBoxInl KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.WASM, true); } + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception { runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInDefault.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 697c5b9eb60..5a466909c1c 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 @@ -40022,6 +40022,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/anonymousObject"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); } + @Test + @TestMetadata("anonymousObjectInCallChildren.kt") + public void testAnonymousObjectInCallChildren() throws Exception { + runTest("compiler/testData/codegen/boxInline/anonymousObject/anonymousObjectInCallChildren.kt"); + } + @Test @TestMetadata("anonymousObjectInDefault.kt") public void testAnonymousObjectInDefault() throws Exception {