FIR checker: fix checker registration

Previously, composed checker passes the `allXXX` flavor of checkers to
each category of checkrs. This makes the composed checkers
non-transparent: behavior changes after composing. In addition, nested
composing would create redundant checkers.

As a result, some checkers registered in the IDE mode
(org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics.AbstractFirIdeDiagnosticsCollector)
are not invoked with the FIR plugin.

This change does two things:
1. pass on checkers to composed checkers without combining
2. use combined checkers in DeclarationCheckersDiagnosticComponent and
   ExpressionCheckersDiagnosticComponent
This commit is contained in:
Tianyu Geng
2021-03-29 14:41:58 -07:00
committed by Dmitriy Novozhilov
parent 65fa2f62bd
commit bd64237519
15 changed files with 96 additions and 84 deletions
+1 -1
View File
@@ -4,7 +4,7 @@
class Pair<A, B>
abstract class C<T : B<Int>, X : (B<Char>) -> Pair<B<Any>, B<A>>>() : B<Any>() { // 2 errors
val a = B<Char>() // error
val a = B<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol@1f33f4d4'">Char</error>>() // error
abstract val x : (B<Char>) -> B<Any>
}
+3 -3
View File
@@ -1,10 +1,10 @@
fun test() {
foo<Int?>()
foo<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol@23ae790a'">Int?</error>>()
foo<Int>()
bar<Int?>()
bar<Int>()
bar<Double?>()
bar<Double>()
bar<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol@ca50b2f'">Double?</error>>()
bar<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol@ca50b2f'">Double</error>>()
1.<error descr="[INAPPLICABLE_CANDIDATE] Inapplicable candidate(s): /buzz">buzz</error><Double>()
}
+3 -3
View File
@@ -6,10 +6,10 @@
class C : A<C>()
val a = B<C>()
val a1 = B<Int>()
val a1 = B<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol@29263cc3'">Int</error>>()
class X<A, B : A>()
val b = X<Any, X<A<C>, C>>()
val b0 = X<Any, Any?>()
val b1 = X<Any, X<A<C>, String>>()
val b0 = X<Any, <error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol@2826285f'">Any?</error>>()
val b1 = X<Any, <error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol@2826285f'">X<A<C>, String></error>>()
+1 -1
View File
@@ -16,7 +16,7 @@ import java.util.*
protected fun <T : Element> initTag(init : T.() -> Unit) : T
{
val tag = T.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: create">create</error>()
val tag = <error descr="[TYPE_PARAMETER_ON_LHS_OF_DOT] Type parameter 'T' cannot have or inherit a companion object, so it cannot be on the left hand side of dot">T</error>.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: create">create</error>()
tag.init()
children.add(tag)
return tag
+6 -6
View File
@@ -22,16 +22,16 @@ class Test1<T>()
{
fun test(t : T) {
T.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>()
T.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>()
<error descr="[TYPE_PARAMETER_ON_LHS_OF_DOT] Type parameter 'T' cannot have or inherit a companion object, so it cannot be on the left hand side of dot">T</error>.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>()
<error descr="[TYPE_PARAMETER_ON_LHS_OF_DOT] Type parameter 'T' cannot have or inherit a companion object, so it cannot be on the left hand side of dot">T</error>.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>()
t.foo()
t.bar()
}
}
fun test() {
Test1<B>()
Test1<A>()
Test1<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol@4c663d20'">B</error>>()
Test1<<error descr="[UPPER_BOUND_VIOLATED] Type argument is not within its bounds: should be subtype of 'org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol@4c663d20'">A</error>>()
Test1<C>()
}
@@ -50,8 +50,8 @@ fun <T> test2(t : T)
T : B,
B : T
{
T.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>()
T.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>()
<error descr="[TYPE_PARAMETER_ON_LHS_OF_DOT] Type parameter 'T' cannot have or inherit a companion object, so it cannot be on the left hand side of dot">T</error>.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: foo">foo</error>()
<error descr="[TYPE_PARAMETER_ON_LHS_OF_DOT] Type parameter 'T' cannot have or inherit a companion object, so it cannot be on the left hand side of dot">T</error>.<error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>()
t.foo()
t.bar()
}