[FIR] Add a REDUNDANT_EXPLICIT_BACKING_FIELD warning

This commit is contained in:
Nikolay Lunyak
2021-09-07 20:52:07 +03:00
committed by TeamCityServer
parent 66beecfb18
commit 3a3ef161d1
7 changed files with 31 additions and 1 deletions
@@ -2448,6 +2448,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.REDUNDANT_EXPLICIT_BACKING_FIELD) { firDiagnostic ->
RedundantExplicitBackingFieldImpl(
firDiagnostic as FirPsiDiagnostic,
token,
)
}
add(FirErrors.ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS) { firDiagnostic ->
AbstractPropertyInPrimaryConstructorParametersImpl(
firDiagnostic as FirPsiDiagnostic,
@@ -1731,6 +1731,10 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = ExplicitBackingFieldInExtension::class
}
abstract class RedundantExplicitBackingField : KtFirDiagnostic<KtBackingField>() {
override val diagnosticClass get() = RedundantExplicitBackingField::class
}
abstract class AbstractPropertyInPrimaryConstructorParameters : KtFirDiagnostic<KtModifierListOwner>() {
override val diagnosticClass get() = AbstractPropertyInPrimaryConstructorParameters::class
}
@@ -2825,6 +2825,13 @@ internal class ExplicitBackingFieldInExtensionImpl(
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class RedundantExplicitBackingFieldImpl(
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.RedundantExplicitBackingField(), KtAbstractFirDiagnostic<KtBackingField> {
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
}
internal class AbstractPropertyInPrimaryConstructorParametersImpl(
firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,