Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/fib.fir.txt
T
Tianyu Geng 765cad8448 FIR checker: substitute type parameters in dispatch receiver type
Consider the following code:

```
fun test(a: List<String>) {
  a.first()
}
```

The dispatch receiver type of `first` in this case is `List<T>` before
this change. After this change, it's `List<String>`.

In addition, this change also replace the dispatch receiver type with
the more specific type if available. For example, consider the following

```
class MyList: ArrayList<String>()

fun test(a: MyList) {
  a.get(0)
}
```
The dispatch receiver type of `get` is `MyList`, instead of
`ArrayList<String>`. That is, a fake override is created in this case.
2021-09-17 01:59:06 +03:00

24 lines
990 B
Plaintext
Vendored

FILE: fib.kt
public final fun fibIterative(n: R|kotlin/Int|): R|kotlin/Int| {
when () {
CMP(<, R|<local>/n|.R|kotlin/Int.compareTo|(Int(2))) -> {
^fibIterative Int(1)
}
}
lvar current: R|kotlin/Int| = Int(1)
lvar prev: R|kotlin/Int| = Int(1)
{
lval <iterator>: R|kotlin/collections/IntIterator| = Int(2).R|kotlin/Int.rangeTo|(R|<local>/n|).R|kotlin/ranges/IntProgression.iterator|()
while(R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/IntIterator.hasNext: R|kotlin/Boolean|>|()) {
lval i: R|kotlin/Int| = R|<local>/<iterator>|.R|kotlin/collections/IntIterator.next|()
lval temp: R|kotlin/Int| = R|<local>/current|
R|<local>/current| = R|<local>/current|.R|kotlin/Int.plus|(R|<local>/prev|)
R|<local>/prev| = R|<local>/temp|
}
}
^fibIterative R|<local>/current|
}