Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/expresssions/enumValues.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

35 lines
1.4 KiB
Plaintext
Vendored

FILE: enumValues.kt
public final enum class MyEnum : R|kotlin/Enum<MyEnum>| {
private constructor(): R|MyEnum| {
super<R|kotlin/Enum<MyEnum>|>()
}
public final static enum entry FIRST: R|MyEnum|
public final static enum entry SECOND: R|MyEnum|
public final static enum entry LAST: R|MyEnum|
public final fun bar(): R|kotlin/Int| {
^bar Int(42)
}
public final static fun values(): R|kotlin/Array<MyEnum>| {
}
public final static fun valueOf(value: R|kotlin/String|): R|MyEnum| {
}
}
public final fun foo(): R|kotlin/Unit| {
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|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|()
}
}
lval first: R|MyEnum| = Q|MyEnum|.R|/MyEnum.valueOf|(String(FIRST))
lval last: R|MyEnum| = Q|MyEnum|.R|/MyEnum.valueOf|(String(LAST))
}