Files
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

32 lines
1.1 KiB
Plaintext
Vendored

FILE: implicitReceiverAsWhenSubject.kt
public final fun R|kotlin/Any|.test_1(): R|kotlin/Int| {
^test_1 when (this@R|/test_1|) {
($subj$ is R|kotlin/collections/List<*>|) -> {
this@R|/test_1|.R|SubstitutionOverride<kotlin/collections/List.size: R|kotlin/Int|>|
}
($subj$ is R|kotlin/String|) -> {
this@R|/test_1|.R|kotlin/String.length|
}
else -> {
Int(0)
}
}
}
public final fun R|kotlin/Any|.test_2(): R|kotlin/Int| {
^test_2 when (lval x: R|kotlin/Any| = this@R|/test_2|) {
($subj$ is R|kotlin/collections/List<*>|) -> {
R|<local>/x|.R|SubstitutionOverride<kotlin/collections/List.size: R|kotlin/Int|>|
this@R|/test_2|.R|SubstitutionOverride<kotlin/collections/List.size: R|kotlin/Int|>|
}
($subj$ is R|kotlin/String|) -> {
R|<local>/x|.R|kotlin/String.length|
this@R|/test_2|.R|kotlin/String.length|
}
else -> {
Int(0)
}
}
}