[FIR] Implement warnings for java nullability type mismatch

#KT-56989
This commit is contained in:
Kirill Rakhman
2023-09-20 15:34:48 +02:00
committed by Space Team
parent 1ecbc094ec
commit a6fdeeb7df
158 changed files with 741 additions and 2021 deletions
@@ -5033,6 +5033,22 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirJvmErrors.RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS) { firDiagnostic ->
ReceiverNullabilityMismatchBasedOnJavaAnnotationsImpl(
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b),
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirJvmErrors.NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS) { firDiagnostic ->
NullabilityMismatchBasedOnJavaAnnotationsImpl(
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.b),
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirJvmErrors.UPPER_BOUND_CANNOT_BE_ARRAY) { firDiagnostic ->
UpperBoundCannotBeArrayImpl(
firDiagnostic as KtPsiDiagnostic,
@@ -3501,6 +3501,18 @@ sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
val actualType: KtType
}
interface ReceiverNullabilityMismatchBasedOnJavaAnnotations : KtFirDiagnostic<PsiElement> {
override val diagnosticClass get() = ReceiverNullabilityMismatchBasedOnJavaAnnotations::class
val actualType: KtType
val expectedType: KtType
}
interface NullabilityMismatchBasedOnJavaAnnotations : KtFirDiagnostic<PsiElement> {
override val diagnosticClass get() = NullabilityMismatchBasedOnJavaAnnotations::class
val actualType: KtType
val expectedType: KtType
}
interface UpperBoundCannotBeArray : KtFirDiagnostic<PsiElement> {
override val diagnosticClass get() = UpperBoundCannotBeArray::class
}
@@ -4224,6 +4224,20 @@ internal class JavaTypeMismatchImpl(
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<KtExpression>(firDiagnostic, token), KtFirDiagnostic.JavaTypeMismatch
internal class ReceiverNullabilityMismatchBasedOnJavaAnnotationsImpl(
override val actualType: KtType,
override val expectedType: KtType,
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.ReceiverNullabilityMismatchBasedOnJavaAnnotations
internal class NullabilityMismatchBasedOnJavaAnnotationsImpl(
override val actualType: KtType,
override val expectedType: KtType,
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtFirDiagnostic.NullabilityMismatchBasedOnJavaAnnotations
internal class UpperBoundCannotBeArrayImpl(
firDiagnostic: KtPsiDiagnostic,
token: KtLifetimeToken,