[FIR] Improve INVISIBLE_REFERENCE message

Report the nearest invisible containing declaration in cases where
the declaration itself is visible.

#KT-53820 Fixed
This commit is contained in:
Kirill Rakhman
2023-06-19 15:02:57 +02:00
committed by Space Team
parent 6a073e0b17
commit 911e62257a
24 changed files with 237 additions and 98 deletions
@@ -256,6 +256,8 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
add(FirErrors.INVISIBLE_REFERENCE) { firDiagnostic ->
InvisibleReferenceImpl(
firSymbolBuilder.buildSymbol(firDiagnostic.a),
firDiagnostic.b,
firDiagnostic.c,
firDiagnostic as KtPsiDiagnostic,
token,
)
@@ -220,6 +220,8 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
interface InvisibleReference : KtFirDiagnostic<PsiElement> {
override val diagnosticClass get() = InvisibleReference::class
val reference: KtSymbol
val visible: Visibility
val containingDeclaration: ClassId?
}
interface UnresolvedReference : KtFirDiagnostic<PsiElement> {
@@ -248,6 +248,8 @@ internal class InvisibleSetterImpl(
internal class InvisibleReferenceImpl(
override val reference: KtSymbol,
override val visible: Visibility,
override val containingDeclaration: ClassId?,
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.InvisibleReference