diff --git a/compiler/fir/resolve/testData/resolve/fib.kt b/compiler/fir/resolve/testData/resolve/fib.kt new file mode 100644 index 00000000000..d3bf182815c --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/fib.kt @@ -0,0 +1,11 @@ +fun fibIterative(n: Int): Int { + if (n < 2) return 1 + var current = 1 + var prev = 1 + for (i in 2..n) { + val temp = current + current += prev + prev = temp + } + return current +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/fib.txt b/compiler/fir/resolve/testData/resolve/fib.txt new file mode 100644 index 00000000000..be7cde8c29f --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/fib.txt @@ -0,0 +1,23 @@ +FILE: fib.kt + public final fun fibIterative(n: R|kotlin/Int|): R|kotlin/Int| { + when () { + <(R|/n|, Int(2)) -> { + ^fibIterative Int(1) + } + else -> { + } + } + + lvar current: R|kotlin/Int| = Int(1) + lvar prev: R|kotlin/Int| = Int(1) + lval : R|kotlin/ranges/IntRange| = Int(2).R|kotlin/Int.rangeTo|(R|/n|) + lval : R|kotlin/collections/IntIterator| = R|/|.R|kotlin/ranges/IntProgression.iterator|() + while(R|/|.R|FakeOverride|()) { + lval i: R|kotlin/Int| = R|/|.R|kotlin/collections/IntIterator.next|() + lval temp: R|kotlin/Int| = R|/current| + R|/current| += R|/prev| + R|/prev| = R|/temp| + } + + ^fibIterative R|/current| + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java index c5fdb25201a..8a577758062 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java @@ -64,6 +64,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase { runTest("compiler/fir/resolve/testData/resolve/fakeRecursiveTypealias.kt"); } + @TestMetadata("fib.kt") + public void testFib() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/fib.kt"); + } + @TestMetadata("ft.kt") public void testFt() throws Exception { runTest("compiler/fir/resolve/testData/resolve/ft.kt");