[FIR] Run checkers for FirErrorResolvedQualifier
`INVISIBLE_REFERENCE` may be reported due to CandidateApplicability via a ConeDiagnostic, or in a checker. The former leads to `FirErrorResolvedQualifier`, so the checker is not called. This makes little sense, because CandidateApplicability may result in `NO_COMPANION_OBJECT`, which would prevent other more meaningful diagnostics from being reported (like `API_NOT_AVAILABLE`). If we run checkers for `FirErrorResolvedQualifier` we may get duplicate `INVISIBLE_REFERENCE`. The change in the checker prevents it.
This commit is contained in:
committed by
Space Team
parent
9be819087a
commit
e187c9272d
+6
-1
@@ -11,8 +11,10 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeAlias
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.expandedConeType
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.getOwnerLookupTag
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeVisibilityError
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
@@ -38,7 +40,10 @@ object FirVisibilityQualifierChecker : FirResolvedQualifierChecker() {
|
||||
firClassLikeDeclaration, context.session, firFile, context.containingDeclarations,
|
||||
)
|
||||
) {
|
||||
reporter.reportOn(expression.source, FirErrors.INVISIBLE_REFERENCE, symbol, context)
|
||||
if (expression !is FirErrorResolvedQualifier || expression.diagnostic !is ConeVisibilityError) {
|
||||
reporter.reportOn(expression.source, FirErrors.INVISIBLE_REFERENCE, symbol, context)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -68,6 +68,10 @@ class ExpressionCheckersDiagnosticComponent(
|
||||
checkers.allResolvedQualifierCheckers.check(resolvedQualifier, data)
|
||||
}
|
||||
|
||||
override fun visitErrorResolvedQualifier(errorResolvedQualifier: FirErrorResolvedQualifier, data: CheckerContext) {
|
||||
checkers.allResolvedQualifierCheckers.check(errorResolvedQualifier, data)
|
||||
}
|
||||
|
||||
override fun visitWhenExpression(whenExpression: FirWhenExpression, data: CheckerContext) {
|
||||
checkers.allWhenExpressionCheckers.check(whenExpression, data)
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@ class IllegalVersion()
|
||||
@<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>RequireKotlin<!>("1.2")
|
||||
class LegalMinimum()
|
||||
|
||||
@<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>RequireKotlin<!>("1.2", versionKind = <!NO_COMPANION_OBJECT!>RequireKotlinVersionKind<!>.<!INVISIBLE_REFERENCE!>COMPILER_VERSION<!>, message = "Requires newer compiler version to be inlined correctly.")
|
||||
@<!INVISIBLE_REFERENCE, INVISIBLE_REFERENCE!>RequireKotlin<!>("1.2", versionKind = <!INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>RequireKotlinVersionKind<!>.<!INVISIBLE_REFERENCE!>COMPILER_VERSION<!>, message = "Requires newer compiler version to be inlined correctly.")
|
||||
class LegalStdLib()
|
||||
|
||||
@@ -28,9 +28,9 @@ import a.MyJavaClass
|
||||
|
||||
val <!EXPOSED_PROPERTY_TYPE!>mc1<!> = <!INVISIBLE_REFERENCE!>MyJavaClass<!>()
|
||||
|
||||
val x = <!NO_COMPANION_OBJECT!>MyJavaClass<!>.<!INVISIBLE_REFERENCE!>staticMethod<!>()
|
||||
val y = MyJavaClass.<!NO_COMPANION_OBJECT!>NestedClass<!>.<!INVISIBLE_REFERENCE!>staticMethodOfNested<!>()
|
||||
val <!EXPOSED_PROPERTY_TYPE!>z<!> = <!NO_COMPANION_OBJECT!>MyJavaClass<!>.<!INVISIBLE_REFERENCE!>NestedClass<!>()
|
||||
val x = <!INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>MyJavaClass<!>.<!INVISIBLE_REFERENCE!>staticMethod<!>()
|
||||
val y = MyJavaClass.<!INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>NestedClass<!>.<!INVISIBLE_REFERENCE!>staticMethodOfNested<!>()
|
||||
val <!EXPOSED_PROPERTY_TYPE!>z<!> = <!INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>MyJavaClass<!>.<!INVISIBLE_REFERENCE!>NestedClass<!>()
|
||||
|
||||
//FILE: c.kt
|
||||
package a.c
|
||||
@@ -39,6 +39,6 @@ import a.MyJavaClass
|
||||
|
||||
val <!EXPOSED_PROPERTY_TYPE!>mc1<!> = <!INVISIBLE_REFERENCE!>MyJavaClass<!>()
|
||||
|
||||
val x = <!NO_COMPANION_OBJECT!>MyJavaClass<!>.<!INVISIBLE_REFERENCE!>staticMethod<!>()
|
||||
val y = MyJavaClass.<!NO_COMPANION_OBJECT!>NestedClass<!>.<!INVISIBLE_REFERENCE!>staticMethodOfNested<!>()
|
||||
val <!EXPOSED_PROPERTY_TYPE!>z<!> = <!NO_COMPANION_OBJECT!>MyJavaClass<!>.<!INVISIBLE_REFERENCE!>NestedClass<!>()
|
||||
val x = <!INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>MyJavaClass<!>.<!INVISIBLE_REFERENCE!>staticMethod<!>()
|
||||
val y = MyJavaClass.<!INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>NestedClass<!>.<!INVISIBLE_REFERENCE!>staticMethodOfNested<!>()
|
||||
val <!EXPOSED_PROPERTY_TYPE!>z<!> = <!INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>MyJavaClass<!>.<!INVISIBLE_REFERENCE!>NestedClass<!>()
|
||||
|
||||
+1
-1
@@ -14,5 +14,5 @@ public class Foo {
|
||||
// FILE: 1.kt
|
||||
|
||||
fun main() {
|
||||
javaPackage.Foo.<!NO_COMPANION_OBJECT!>Bar<!>.<!INVISIBLE_REFERENCE!>doSmth<!>()
|
||||
javaPackage.Foo.<!INVISIBLE_REFERENCE, NO_COMPANION_OBJECT!>Bar<!>.<!INVISIBLE_REFERENCE!>doSmth<!>()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
import kotlin.io.path.<!API_NOT_AVAILABLE!>OnErrorResult<!>
|
||||
|
||||
fun fun0 (): Unit {
|
||||
val something1 = <!NO_COMPANION_OBJECT!>OnErrorResult<!>.<!OPT_IN_USAGE_ERROR!>TERMINATE<!>
|
||||
val something1 = <!API_NOT_AVAILABLE, NO_COMPANION_OBJECT, OPT_IN_USAGE_ERROR!>OnErrorResult<!>.<!OPT_IN_USAGE_ERROR!>TERMINATE<!>
|
||||
val something2 = kotlin.io.path.<!API_NOT_AVAILABLE, OPT_IN_USAGE_ERROR!>OnErrorResult<!>.<!OPT_IN_USAGE_ERROR!>TERMINATE<!>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user