[FIR] Add DNN checks

Merge-request: KT-MR-7000
Merged-by: Nikolay Lunyak <lunyak.kolya@mail.ru>
This commit is contained in:
Nikolay Lunyak
2022-09-01 14:25:07 +00:00
committed by Space
parent bb2bee74cf
commit 3d9c77efa8
16 changed files with 124 additions and 26 deletions
@@ -2015,6 +2015,24 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.INCORRECT_LEFT_COMPONENT_OF_INTERSECTION) { firDiagnostic ->
IncorrectLeftComponentOfIntersectionImpl(
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.INCORRECT_RIGHT_COMPONENT_OF_INTERSECTION) { firDiagnostic ->
IncorrectRightComponentOfIntersectionImpl(
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.NULLABLE_ON_DEFINITELY_NOT_NULLABLE) { firDiagnostic ->
NullableOnDefinitelyNotNullableImpl(
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED) { firDiagnostic ->
ExtensionInClassReferenceNotAllowedImpl(
firSymbolBuilder.callableBuilder.buildCallableSymbol(firDiagnostic.a),
@@ -1435,6 +1435,18 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
abstract val causingTypes: String
}
abstract class IncorrectLeftComponentOfIntersection : KtFirDiagnostic<KtTypeReference>() {
override val diagnosticClass get() = IncorrectLeftComponentOfIntersection::class
}
abstract class IncorrectRightComponentOfIntersection : KtFirDiagnostic<KtTypeReference>() {
override val diagnosticClass get() = IncorrectRightComponentOfIntersection::class
}
abstract class NullableOnDefinitelyNotNullable : KtFirDiagnostic<KtTypeReference>() {
override val diagnosticClass get() = NullableOnDefinitelyNotNullable::class
}
abstract class ExtensionInClassReferenceNotAllowed : KtFirDiagnostic<KtExpression>() {
override val diagnosticClass get() = ExtensionInClassReferenceNotAllowed::class
abstract val referencedDeclaration: KtCallableSymbol
@@ -1722,6 +1722,21 @@ internal class InferredTypeVariableIntoPossibleEmptyIntersectionImpl(
override val token: KtLifetimeToken,
) : KtFirDiagnostic.InferredTypeVariableIntoPossibleEmptyIntersection(), KtAbstractFirDiagnostic<PsiElement>
internal class IncorrectLeftComponentOfIntersectionImpl(
override val firDiagnostic: KtPsiDiagnostic,
override val token: KtLifetimeToken,
) : KtFirDiagnostic.IncorrectLeftComponentOfIntersection(), KtAbstractFirDiagnostic<KtTypeReference>
internal class IncorrectRightComponentOfIntersectionImpl(
override val firDiagnostic: KtPsiDiagnostic,
override val token: KtLifetimeToken,
) : KtFirDiagnostic.IncorrectRightComponentOfIntersection(), KtAbstractFirDiagnostic<KtTypeReference>
internal class NullableOnDefinitelyNotNullableImpl(
override val firDiagnostic: KtPsiDiagnostic,
override val token: KtLifetimeToken,
) : KtFirDiagnostic.NullableOnDefinitelyNotNullable(), KtAbstractFirDiagnostic<KtTypeReference>
internal class ExtensionInClassReferenceNotAllowedImpl(
override val referencedDeclaration: KtCallableSymbol,
override val firDiagnostic: KtPsiDiagnostic,