FIR checker: report nullable/non-class LHS of class literals

This commit is contained in:
Jinseong Jeon
2021-03-01 12:36:44 -08:00
committed by Dmitriy Novozhilov
parent a6d1d47918
commit e8028e7825
18 changed files with 162 additions and 38 deletions
@@ -679,6 +679,18 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.CLASS_LITERAL_LHS_NOT_A_CLASS) { firDiagnostic ->
ClassLiteralLhsNotAClassImpl(
firDiagnostic as FirPsiDiagnostic<*>,
token,
)
}
add(FirErrors.NULLABLE_TYPE_IN_CLASS_LITERAL_LHS) { firDiagnostic ->
NullableTypeInClassLiteralLhsImpl(
firDiagnostic as FirPsiDiagnostic<*>,
token,
)
}
add(FirErrors.NOTHING_TO_OVERRIDE) { firDiagnostic ->
NothingToOverrideImpl(
firSymbolBuilder.buildSymbol(firDiagnostic.a as FirDeclaration),
@@ -483,6 +483,14 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = InnerClassOfGenericThrowableSubclass::class
}
abstract class ClassLiteralLhsNotAClass : KtFirDiagnostic<KtExpression>() {
override val diagnosticClass get() = ClassLiteralLhsNotAClass::class
}
abstract class NullableTypeInClassLiteralLhs : KtFirDiagnostic<KtExpression>() {
override val diagnosticClass get() = NullableTypeInClassLiteralLhs::class
}
abstract class NothingToOverride : KtFirDiagnostic<KtModifierListOwner>() {
override val diagnosticClass get() = NothingToOverride::class
abstract val declaration: KtSymbol
@@ -775,6 +775,20 @@ internal class InnerClassOfGenericThrowableSubclassImpl(
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class ClassLiteralLhsNotAClassImpl(
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,
) : KtFirDiagnostic.ClassLiteralLhsNotAClass(), KtAbstractFirDiagnostic<KtExpression> {
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class NullableTypeInClassLiteralLhsImpl(
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,
) : KtFirDiagnostic.NullableTypeInClassLiteralLhs(), KtAbstractFirDiagnostic<KtExpression> {
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class NothingToOverrideImpl(
override val declaration: KtSymbol,
firDiagnostic: FirPsiDiagnostic<*>,