Files
kotlin-fork/compiler/testData/diagnostics/tests/protectedWithGenericsInDifferentPackage.kt
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

42 lines
911 B
Kotlin
Vendored

// FILE: foo/Super.java
package foo
public abstract class Super<T> {
protected abstract String getName();
protected abstract void setName(String s);
protected abstract String getName2();
protected abstract void setName2(String s);
protected abstract void doSomething();
protected abstract void doSomething2();
}
// FILE: bar/Sub.kt
package bar
abstract class Sub<T>: foo.Super<T>() {
abstract override fun getName(): String
abstract override fun setName(s: String)
abstract override fun doSomething()
}
// FILE: foo/test.kt
package foo
fun test(s: bar.Sub<String>) {
s.<!INVISIBLE_MEMBER!>name<!>
s.<!INVISIBLE_MEMBER!>name<!> = ""
s.name2
s.name2 = ""
s.<!INVISIBLE_MEMBER!>doSomething<!>()
s.doSomething2()
val s2: Super<String> = s
s2.name
s2.name = ""
s2.name2
s2.name2 = ""
s2.doSomething()
s2.doSomething2()
}