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:
committed by
teamcityserver
parent
c047adbaec
commit
765cad8448
+2
-2
@@ -54,7 +54,7 @@ digraph boundSmartcastsInBranches_kt {
|
||||
color=blue
|
||||
18 [label="Enter loop condition"];
|
||||
19 [label="Access variable R|<local>/<iterator>|"];
|
||||
20 [label="Function call: R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()"];
|
||||
20 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()"];
|
||||
21 [label="Exit loop condition"];
|
||||
}
|
||||
subgraph cluster_8 {
|
||||
@@ -84,7 +84,7 @@ digraph boundSmartcastsInBranches_kt {
|
||||
35 [label="Enter block"];
|
||||
36 [label="Access variable R|<local>/a|"];
|
||||
37 [label="Assignment: R|<local>/goodA|"];
|
||||
38 [label="Jump: continue@@@[R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()] "];
|
||||
38 [label="Jump: continue@@@[R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()] "];
|
||||
39 [label="Stub" style="filled" fillcolor=gray];
|
||||
40 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,12 +12,12 @@ FILE: boundSmartcastsInBranches.kt
|
||||
lvar goodA: R|A?| = Null(null)
|
||||
{
|
||||
lval <iterator>: R|kotlin/collections/Iterator<A>| = R|<local>/list|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<A>|>|()
|
||||
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
|
||||
while(R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()) {
|
||||
lval a: R|A| = R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|A|>|()
|
||||
when () {
|
||||
==(R|<local>/goodA|, Null(null)) -> {
|
||||
R|<local>/goodA| = R|<local>/a|
|
||||
continue@@@[R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()]
|
||||
continue@@@[R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user