diff --git a/compiler/testData/codegen/box/constructorCall/loopInInlineFunInSuperConstructorCallWithEnabledNormalization.kt b/compiler/testData/codegen/box/constructorCall/loopInInlineFunInSuperConstructorCallWithEnabledNormalization.kt new file mode 100644 index 00000000000..fc914fa55c6 --- /dev/null +++ b/compiler/testData/codegen/box/constructorCall/loopInInlineFunInSuperConstructorCallWithEnabledNormalization.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=enable +open class A(val s: String) + +inline fun test(crossinline z: () -> String): String { + return object : A(listOf(1).map { it.toString() }.joinToString()) { + val value = z() + }.value +} + +fun box(): String { + return test { "OK" } +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/constructorCall/loopInInlineFunWithEnabledNormalization.kt b/compiler/testData/codegen/box/constructorCall/loopInInlineFunWithEnabledNormalization.kt new file mode 100644 index 00000000000..1edbb009b57 --- /dev/null +++ b/compiler/testData/codegen/box/constructorCall/loopInInlineFunWithEnabledNormalization.kt @@ -0,0 +1,41 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// KOTLIN_CONFIGURATION_FLAGS: CONSTRUCTOR_CALL_NORMALIZATION_MODE=enable +// FILE: test.kt +fun box(): String { + Foo( + logged("i", listOf(1, 2, 3).map { it + 1 }.first()), + logged("j", + Foo( + logged("k", listOf(1, 2, 3).map { it + 1 }.first()), + null + ) + ) + ) + + val result = log.toString() + if (result != "ikj") return "Fail: '$result'" + + return "OK" +} + +// FILE: util.kt +val log = StringBuilder() + +fun logged(msg: String, value: T): T { + log.append(msg) + return value +} + +// FILE: Foo.kt +class Foo(i: Int, j: Foo?) { + init { + log.append("") + } + + companion object { + init { + log.append("") + } + } +} diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 749201f727e..db686cc9a06 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -4337,6 +4337,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("loopInInlineFunInSuperConstructorCallWithEnabledNormalization.kt") + public void testLoopInInlineFunInSuperConstructorCallWithEnabledNormalization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/loopInInlineFunInSuperConstructorCallWithEnabledNormalization.kt"); + doTest(fileName); + } + + @TestMetadata("loopInInlineFunWithEnabledNormalization.kt") + public void testLoopInInlineFunWithEnabledNormalization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/loopInInlineFunWithEnabledNormalization.kt"); + doTest(fileName); + } + @TestMetadata("nestedConstructorCallWithJumpOutInConstructorArguments.kt") public void testNestedConstructorCallWithJumpOutInConstructorArguments() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/nestedConstructorCallWithJumpOutInConstructorArguments.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 819a1adf761..9167bf056f1 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -4337,6 +4337,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("loopInInlineFunInSuperConstructorCallWithEnabledNormalization.kt") + public void testLoopInInlineFunInSuperConstructorCallWithEnabledNormalization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/loopInInlineFunInSuperConstructorCallWithEnabledNormalization.kt"); + doTest(fileName); + } + + @TestMetadata("loopInInlineFunWithEnabledNormalization.kt") + public void testLoopInInlineFunWithEnabledNormalization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/loopInInlineFunWithEnabledNormalization.kt"); + doTest(fileName); + } + @TestMetadata("nestedConstructorCallWithJumpOutInConstructorArguments.kt") public void testNestedConstructorCallWithJumpOutInConstructorArguments() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/nestedConstructorCallWithJumpOutInConstructorArguments.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 57c4e624606..0373b3d7d5a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -4337,6 +4337,18 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("loopInInlineFunInSuperConstructorCallWithEnabledNormalization.kt") + public void testLoopInInlineFunInSuperConstructorCallWithEnabledNormalization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/loopInInlineFunInSuperConstructorCallWithEnabledNormalization.kt"); + doTest(fileName); + } + + @TestMetadata("loopInInlineFunWithEnabledNormalization.kt") + public void testLoopInInlineFunWithEnabledNormalization() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/loopInInlineFunWithEnabledNormalization.kt"); + doTest(fileName); + } + @TestMetadata("nestedConstructorCallWithJumpOutInConstructorArguments.kt") public void testNestedConstructorCallWithJumpOutInConstructorArguments() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/constructorCall/nestedConstructorCallWithJumpOutInConstructorArguments.kt");