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
@@ -58,7 +58,7 @@ FILE fqName:<root> fileName:/noSymbolForIntRangeIterator.kt
$this: CONST Int type=kotlin.Int value=0
other: GET_VAR 'val x: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
WHILE label=null origin=FOR_LOOP_INNER_WHILE
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT
$this: GET_VAR 'val tmp_1: kotlin.collections.IntIterator [val] declared in <root>.test.localFunc' type=kotlin.collections.IntIterator origin=null
body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE
VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val]
@@ -78,7 +78,7 @@ FILE fqName:<root> fileName:/noSymbolForIntRangeIterator.kt
$this: CONST Int type=kotlin.Int value=0
other: GET_VAR 'val y: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
WHILE label=null origin=FOR_LOOP_INNER_WHILE
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT
condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT
$this: GET_VAR 'val tmp_2: kotlin.collections.IntIterator [val] declared in <root>.test.localFunc.<anonymous>' type=kotlin.collections.IntIterator origin=null
body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE
VAR FOR_LOOP_VARIABLE name:j type:kotlin.Int [val]