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
+3
-3
@@ -32,7 +32,7 @@ fun case_2() {
|
||||
class case_4 : ClassLevel3() {
|
||||
|
||||
fun <T : Number?>T.case_4_1(): Boolean {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (<!UNRESOLVED_LABEL!>this@case_4<!> !is ClassLevel1)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns(false) implies (this<!UNRESOLVED_LABEL!>@case_4<!> !is ClassLevel1)<!> }
|
||||
return this == null
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ class case_4 : ClassLevel3() {
|
||||
class case_5<T> : ClassLevel5() {
|
||||
inner class case_5_1 {
|
||||
fun <K : Number?>K.case_5_1_1() {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (<!UNRESOLVED_LABEL!>this@case_5_1<!> !is ClassLevel1 && <!UNRESOLVED_LABEL!>this@case_5_1<!> != null || <!UNRESOLVED_LABEL!>this@case_5<!> is ClassLevel1 && this@case_5_1_1 is Float)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this<!UNRESOLVED_LABEL!>@case_5_1<!> !is ClassLevel1 && this<!UNRESOLVED_LABEL!>@case_5_1<!> != null || this<!UNRESOLVED_LABEL!>@case_5<!> is ClassLevel1 && this@case_5_1_1 is Float)<!> }
|
||||
if (!(this@case_5_1 !is ClassLevel1 && <!SENSELESS_COMPARISON!>this@case_5_1 != null<!> || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> && this is Float)) throw Exception()
|
||||
}
|
||||
|
||||
fun case_5_1_2() {
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (<!UNRESOLVED_LABEL!>this@case_5_1<!> !is ClassLevel1 || <!UNRESOLVED_LABEL!>this@case_5<!> is ClassLevel1 || <!UNRESOLVED_LABEL!>this@case_5_1<!> == null)<!> }
|
||||
contract { <!ERROR_IN_CONTRACT_DESCRIPTION!>returns() implies (this<!UNRESOLVED_LABEL!>@case_5_1<!> !is ClassLevel1 || this<!UNRESOLVED_LABEL!>@case_5<!> is ClassLevel1 || this<!UNRESOLVED_LABEL!>@case_5_1<!> == null)<!> }
|
||||
if (!(this@case_5_1 !is ClassLevel1 || <!USELESS_IS_CHECK!>this@case_5 is ClassLevel1<!> || <!SENSELESS_COMPARISON!>this@case_5_1 == null<!>)) throw Exception()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user