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
@@ -23,11 +23,11 @@ FILE: qualifiedSupertypeExtendedByOtherSupertype.kt
}
public final fun test(): R|kotlin/Unit| {
this@R|/Test|.super<R|IBase<kotlin/String>|>.R|/IBase.foo|()
this@R|/Test|.super<R|IBase<kotlin/String>|>.R|/IBase.bar|()
this@R|/Test|.super<R|IDerived<kotlin/String>|>.R|/IDerived.foo|()
this@R|/Test|.super<R|IDerived<kotlin/String>|>.R|/IBase.bar|()
this@R|/Test|.super<R|IDerived<kotlin/String>|>.R|/IDerived.qux|()
this@R|/Test|.super<R|IBase<kotlin/String>|>.R|SubstitutionOverride</IBase.foo: R|kotlin/Unit|>|()
this@R|/Test|.super<R|IBase<kotlin/String>|>.R|SubstitutionOverride</IBase.bar: R|kotlin/Unit|>|()
this@R|/Test|.super<R|IDerived<kotlin/String>|>.R|SubstitutionOverride</IDerived.foo: R|kotlin/Unit|>|()
this@R|/Test|.super<R|IDerived<kotlin/String>|>.R|SubstitutionOverride</IDerived.bar: R|kotlin/Unit|>|()
this@R|/Test|.super<R|IDerived<kotlin/String>|>.R|SubstitutionOverride</IDerived.qux: R|kotlin/Unit|>|()
}
}
@@ -37,13 +37,13 @@ FILE: qualifiedSupertypeExtendedByOtherSupertype.kt
}
public final fun test(): R|kotlin/Unit| {
this@R|/Test2|.super<R|IBase<kotlin/String>|>.R|/IBase.foo|()
this@R|/Test2|.super<R|IBase<kotlin/String>|>.R|/IBase.bar|()
this@R|/Test2|.super<R|IBase<kotlin/String>|>.R|/IBase.foo|()
this@R|/Test2|.super<R|IBase<kotlin/String>|>.R|/IBase.bar|()
this@R|/Test2|.super<R|IDerived<kotlin/String>|>.R|/IDerived.foo|()
this@R|/Test2|.super<R|IDerived<kotlin/String>|>.R|/IBase.bar|()
this@R|/Test2|.super<R|IDerived<kotlin/String>|>.R|/IDerived.qux|()
this@R|/Test2|.super<R|IBase<kotlin/String>|>.R|SubstitutionOverride</IBase.foo: R|kotlin/Unit|>|()
this@R|/Test2|.super<R|IBase<kotlin/String>|>.R|SubstitutionOverride</IBase.bar: R|kotlin/Unit|>|()
this@R|/Test2|.super<R|IBase<kotlin/String>|>.R|SubstitutionOverride</IBase.foo: R|kotlin/Unit|>|()
this@R|/Test2|.super<R|IBase<kotlin/String>|>.R|SubstitutionOverride</IBase.bar: R|kotlin/Unit|>|()
this@R|/Test2|.super<R|IDerived<kotlin/String>|>.R|SubstitutionOverride</IDerived.foo: R|kotlin/Unit|>|()
this@R|/Test2|.super<R|IDerived<kotlin/String>|>.R|SubstitutionOverride</IDerived.bar: R|kotlin/Unit|>|()
this@R|/Test2|.super<R|IDerived<kotlin/String>|>.R|SubstitutionOverride</IDerived.qux: R|kotlin/Unit|>|()
}
}