FIR: introduce diagnostic NESTED_CLASS_NOT_ALLOWED
This commit is contained in:
committed by
Mikhail Glukhikh
parent
c5cabce2d5
commit
724ca1d3ee
+4
-1
@@ -173,7 +173,10 @@ internal class NonReanalyzableDeclarationStructureElement(
|
||||
firFile,
|
||||
onDeclarationEnter = { firDeclaration ->
|
||||
when {
|
||||
firDeclaration.isGeneratedDeclaration -> DiagnosticCollectorDeclarationAction.SKIP
|
||||
// Some generated declaration contains structures that we need to check. For example the FIR representation of an
|
||||
// enum entry initializer, when present, is a generated anonymous object of kind `ENUM_ENTRY`.
|
||||
firDeclaration.isGeneratedDeclaration ->
|
||||
DiagnosticCollectorDeclarationAction.SKIP_CURRENT_DECLARATION_AND_CHECK_NESTED
|
||||
firDeclaration is FirFile -> DiagnosticCollectorDeclarationAction.CHECK_CURRENT_DECLARATION_AND_CHECK_NESTED
|
||||
firDeclaration == fir -> {
|
||||
inCurrentDeclaration = true
|
||||
|
||||
+7
@@ -99,6 +99,13 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.NESTED_CLASS_NOT_ALLOWED) { firDiagnostic ->
|
||||
NestedClassNotAllowedImpl(
|
||||
firDiagnostic.a,
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.HIDDEN) { firDiagnostic ->
|
||||
HiddenImpl(
|
||||
firSymbolBuilder.buildSymbol(firDiagnostic.a.fir as FirDeclaration),
|
||||
|
||||
+5
@@ -83,6 +83,11 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = DelegationInInterface::class
|
||||
}
|
||||
|
||||
abstract class NestedClassNotAllowed : KtFirDiagnostic<KtNamedDeclaration>() {
|
||||
override val diagnosticClass get() = NestedClassNotAllowed::class
|
||||
abstract val declaration: String
|
||||
}
|
||||
|
||||
abstract class Hidden : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = Hidden::class
|
||||
abstract val hidden: KtSymbol
|
||||
|
||||
+8
@@ -114,6 +114,14 @@ internal class DelegationInInterfaceImpl(
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class NestedClassNotAllowedImpl(
|
||||
override val declaration: String,
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.NestedClassNotAllowed(), KtAbstractFirDiagnostic<KtNamedDeclaration> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class HiddenImpl(
|
||||
override val hidden: KtSymbol,
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
|
||||
Reference in New Issue
Block a user