diff --git a/compiler/testData/codegen/boxInline/special/loopInStoreLoadChains.kt b/compiler/testData/codegen/boxInline/special/loopInStoreLoadChains.kt new file mode 100644 index 00000000000..1d368d6595e --- /dev/null +++ b/compiler/testData/codegen/boxInline/special/loopInStoreLoadChains.kt @@ -0,0 +1,19 @@ +// NO_CHECK_LAMBDA_INLINING + +// FILE: 1.kt +inline fun test(noinline foo: () -> String, noinline bar: () -> String): String { + var vfoo = foo + var vbar = bar + var vres = foo + for (i in 1 .. 4) { + vres = vbar + vbar = vfoo + vfoo = vres + } + return vres() +} + + +// FILE: 2.kt +fun box(): String = + test({ "OK" }, { "wrong lambda" }) \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/special/loopInStoreLoadChains2.kt b/compiler/testData/codegen/boxInline/special/loopInStoreLoadChains2.kt new file mode 100644 index 00000000000..9e0289e38d0 --- /dev/null +++ b/compiler/testData/codegen/boxInline/special/loopInStoreLoadChains2.kt @@ -0,0 +1,25 @@ +// FILE: 1.kt +inline fun cycle(p: String): String { + var z = p + var x = z + for (i in 1..4) { + z = x + x = z + } + return z +} + +inline fun test(crossinline foo: String.() -> String): String { + val cycle = cycle("123"); + + { + cycle.foo() + }() + + + return cycle.foo() +} + + +// FILE: 2.kt +fun box(): String = test { "OK" } \ 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 c2e92e0300e..9a9efe63924 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -2432,6 +2432,18 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo doTest(fileName); } + @TestMetadata("loopInStoreLoadChains.kt") + public void testLoopInStoreLoadChains() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/special/loopInStoreLoadChains.kt"); + doTest(fileName); + } + + @TestMetadata("loopInStoreLoadChains2.kt") + public void testLoopInStoreLoadChains2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/special/loopInStoreLoadChains2.kt"); + doTest(fileName); + } + @TestMetadata("plusAssign.kt") public void testPlusAssign() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/special/plusAssign.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 92a4e303c0c..e76cae75a8c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -2432,6 +2432,18 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi doTest(fileName); } + @TestMetadata("loopInStoreLoadChains.kt") + public void testLoopInStoreLoadChains() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/special/loopInStoreLoadChains.kt"); + doTest(fileName); + } + + @TestMetadata("loopInStoreLoadChains2.kt") + public void testLoopInStoreLoadChains2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/special/loopInStoreLoadChains2.kt"); + doTest(fileName); + } + @TestMetadata("plusAssign.kt") public void testPlusAssign() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/special/plusAssign.kt");