280c445783
This change touches the following diagnostics to make them behave closer
to FE1.0
* SUPER_NOT_AVAILABLE
* SUPER_IS_NOT_AN_EXPRESSION
* INSTANCE_ACCESS_BEFORE_SUPER_CALL
* NOT_A_SUPERTYPE
Other than tweaking the diagnostics, this change also alters resolution
by consider marking `super` with mismatched type parameter as
errorenous. As a result, the following code no longer resolves.
```
class A: B() {
fun test() {
super<String>.length
// ^^^^^^ FIR currently resolves this to `String.length`.
// With this change, `length` becomes unresolved
// instead
}
}
```
Also, now we report `UNRESOLVED_LABEL` on unresolved label on `super`
reference, though FE1.0 reports `UNRESOLVED_REFERENCE`.
All the errors above are reported as ConeDiagnostics and hence some
checkers are deleted.
In addition, it also suppresses more downstream (mostly unresolved)
errors if the receiver has errors. FE1.0 doesn't do it for all the cases
we have here. But it seems nicer to reduce these "redundant" unresolved
errors.
65 lines
1.6 KiB
Kotlin
Vendored
65 lines
1.6 KiB
Kotlin
Vendored
package example
|
|
|
|
interface T {
|
|
fun foo() {}
|
|
}
|
|
open class C() {
|
|
fun bar() {}
|
|
}
|
|
|
|
class A<E>() : C(), T {
|
|
|
|
fun test() {
|
|
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
|
|
<!SUPER_IS_NOT_AN_EXPRESSION!>super<T><!>
|
|
super.foo()
|
|
super<T>.foo()
|
|
super<C>.bar()
|
|
super<T>@A.foo()
|
|
super<C>@A.bar()
|
|
super<<!NOT_A_SUPERTYPE!>E<!>>.bar()
|
|
super<<!NOT_A_SUPERTYPE!>E<!>>@A.bar()
|
|
super<<!NOT_A_SUPERTYPE!>Int<!>>.foo()
|
|
super<<!SYNTAX!><!>>.<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
super<<!NOT_A_SUPERTYPE!>() -> Unit<!>>.foo()
|
|
super<<!NOT_A_SUPERTYPE!>Unit<!>>.foo()
|
|
super<T><!UNRESOLVED_LABEL!>@B<!>.foo()
|
|
super<C><!UNRESOLVED_LABEL!>@B<!>.bar()
|
|
}
|
|
|
|
inner class B : T {
|
|
fun test() {
|
|
super<T>.foo();
|
|
super<<!NOT_A_SUPERTYPE!>C<!>>.bar()
|
|
super<C>@A.bar()
|
|
super<T>@A.foo()
|
|
super<T>@B.foo()
|
|
super<<!NOT_A_SUPERTYPE!>C<!>>@B.foo()
|
|
super.foo()
|
|
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
|
|
<!SUPER_IS_NOT_AN_EXPRESSION!>super<T><!>
|
|
}
|
|
}
|
|
}
|
|
|
|
interface G<T> {
|
|
fun foo() {}
|
|
}
|
|
|
|
class CG : G<Int> {
|
|
fun test() {
|
|
super<G>.foo() // OK
|
|
super<G<!TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER!><Int><!>>.foo() // Warning
|
|
super<<!NOT_A_SUPERTYPE!>G<E><!>>.foo() // Error
|
|
super<<!NOT_A_SUPERTYPE!>G<String><!>>.foo() // Error
|
|
}
|
|
}
|
|
|
|
// The case when no supertype is resolved
|
|
class ERROR<E>() : <!UNRESOLVED_REFERENCE!>UR<!> {
|
|
|
|
fun test() {
|
|
super.<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
}
|
|
}
|