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.
This commit is contained in:
Tianyu Geng
2021-08-06 14:56:37 -07:00
committed by teamcityserver
parent c047adbaec
commit 765cad8448
61 changed files with 342 additions and 145 deletions
@@ -22,7 +22,7 @@ FILE: enumValues.kt
lval values: R|kotlin/Array<MyEnum>| = Q|MyEnum|.R|/MyEnum.values|()
{
lval <iterator>: R|kotlin/collections/Iterator<MyEnum>| = R|<local>/values|.R|SubstitutionOverride<kotlin/Array.iterator: R|kotlin/collections/Iterator<MyEnum>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
while(R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()) {
lval value: R|MyEnum| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|MyEnum|>|()
R|<local>/value|.R|/MyEnum.bar|()
}
@@ -5,7 +5,7 @@ FILE: test.kt
}
public final override fun getLookupString(): R|kotlin/String| {
^getLookupString this@R|/MyDecorator|.R|/MyDecorator.delegate|.R|/LookupElement.lookupString|
^getLookupString this@R|/MyDecorator|.R|/Decorator.delegate|.R|/LookupElement.lookupString|
}
}
@@ -30,6 +30,6 @@ FILE: importedReceiver.kt
(Q|My|, String()).R|/My.bar|<R|kotlin/String|>()
Q|My|.R|/My.baz|()
(Q|My|, Boolean(true)).R|/My.gau|()
Q|My|.R|/Your.wat|()
Q|My|.R|SubstitutionOverride</My.wat: R|kotlin/Unit|>|()
(Q|My|, Boolean(false)).R|SubstitutionOverride</My.watwat: R|kotlin/Unit|>|<R|kotlin/Boolean|>()
}