FIR checker: check super reference
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.
This commit is contained in:
committed by
Ivan Kochurkin
parent
bcf6202863
commit
280c445783
+1
-1
@@ -37,7 +37,7 @@ class F(var a: Int, b: Int, closure: () -> Unit, instance: F?) {
|
||||
val a = 10
|
||||
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>
|
||||
test(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>)
|
||||
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>a<!> = 20
|
||||
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.a = 20
|
||||
}, <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>) {
|
||||
this.a = 30
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ FILE: notASupertype.kt
|
||||
}
|
||||
|
||||
public final fun g(): R|kotlin/Unit| {
|
||||
this@R|/B|.super<R|kotlin/String|>.<Unresolved name: f>#()
|
||||
this@R|/B|.super<<ERROR TYPE REF: Not a super type>>.<Unresolved name: f>#()
|
||||
this@R|/B|.super<R|A|>.R|/A.f|()
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ open class A {
|
||||
|
||||
class B : <!SUPERTYPE_NOT_INITIALIZED!>A<!> {
|
||||
fun g() {
|
||||
<!NOT_A_SUPERTYPE!>super<String><!>.<!UNRESOLVED_REFERENCE!>f<!>()
|
||||
super<<!NOT_A_SUPERTYPE!>String<!>>.f()
|
||||
super<A>.f()
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,12 +1,12 @@
|
||||
FILE: superNotAvailable.kt
|
||||
public final fun R|kotlin/String|.f(): R|kotlin/Unit| {
|
||||
super<<ERROR TYPE REF: No super type>>@f#.<Unresolved name: compareTo>#(String())
|
||||
super<<ERROR TYPE REF: No super type>>.<Unresolved name: compareTo>#(String())
|
||||
<Super not available>#.<Unresolved name: compareTo>#(String())
|
||||
<Super not available>#.<Unresolved name: compareTo>#(String())
|
||||
}
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
super<<ERROR TYPE REF: No super type>>
|
||||
super<<ERROR TYPE REF: No super type>>.<Unresolved name: foo>#()
|
||||
super<R|kotlin/Nothing|>.<Unresolved name: foo>#()
|
||||
<Super not allowed>#
|
||||
<Super not available>#.<Unresolved name: foo>#()
|
||||
<Super not available>#.<Unresolved name: foo>#()
|
||||
}
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
|
||||
+5
-5
@@ -1,12 +1,12 @@
|
||||
fun String.f() {
|
||||
<!SUPER_NOT_AVAILABLE!>super@f<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
<!SUPER_NOT_AVAILABLE!>super@f<!>.compareTo("")
|
||||
<!SUPER_NOT_AVAILABLE!>super<!>.compareTo("")
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
<!SUPER_NOT_AVAILABLE!>super<!>
|
||||
<!SUPER_NOT_AVAILABLE!>super<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>
|
||||
<!SUPER_NOT_AVAILABLE!>super<!>.foo()
|
||||
<!SUPER_NOT_AVAILABLE!>super<Nothing><!>.foo()
|
||||
}
|
||||
|
||||
class A {
|
||||
|
||||
Reference in New Issue
Block a user