[FIR] Add REDUNDANT_NULLABLE diagnostics

This commit is contained in:
Ivan Kochurkin
2021-11-19 16:21:51 +03:00
committed by TeamCityServer
parent 4caf3c5e83
commit 51b73bb6ae
37 changed files with 233 additions and 87 deletions
@@ -1891,6 +1891,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.REDUNDANT_NULLABLE) { firDiagnostic ->
RedundantNullableImpl(
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED) { firDiagnostic ->
ExtensionInClassReferenceNotAllowedImpl(
firSymbolBuilder.callableBuilder.buildCallableSymbol(firDiagnostic.a.fir),
@@ -1348,6 +1348,10 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
abstract val isCastToNotNull: Boolean
}
abstract class RedundantNullable : KtFirDiagnostic<KtTypeReference>() {
override val diagnosticClass get() = RedundantNullable::class
}
abstract class ExtensionInClassReferenceNotAllowed : KtFirDiagnostic<KtExpression>() {
override val diagnosticClass get() = ExtensionInClassReferenceNotAllowed::class
abstract val referencedDeclaration: KtCallableSymbol
@@ -1617,6 +1617,11 @@ internal class SmartcastImpossibleImpl(
override val token: ValidityToken,
) : KtFirDiagnostic.SmartcastImpossible(), KtAbstractFirDiagnostic<KtExpression>
internal class RedundantNullableImpl(
override val firDiagnostic: KtPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.RedundantNullable(), KtAbstractFirDiagnostic<KtTypeReference>
internal class ExtensionInClassReferenceNotAllowedImpl(
override val referencedDeclaration: KtCallableSymbol,
override val firDiagnostic: KtPsiDiagnostic,
@@ -90,7 +90,7 @@ private object CheckersFactory {
}
private fun createTypeCheckers(useExtendedCheckers: Boolean): TypeCheckers? =
if (useExtendedCheckers) null else CommonTypeCheckers
if (useExtendedCheckers) ExtendedTypeCheckers else CommonTypeCheckers
@OptIn(ExperimentalStdlibApi::class)