K2: support ForbidInferringTypeVariablesIntoEmptyIntersection on/off

This commit is contained in:
Mikhail Glukhikh
2023-02-28 09:40:19 +01:00
committed by Space Team
parent f7544aff62
commit b64cb67370
43 changed files with 86 additions and 248 deletions
@@ -2224,8 +2224,20 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION) { firDiagnostic ->
InferredTypeVariableIntoEmptyIntersectionImpl(
add(FirErrors.INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION.errorFactory) { firDiagnostic ->
InferredTypeVariableIntoEmptyIntersectionErrorImpl(
firDiagnostic.a,
firDiagnostic.b.map { coneKotlinType ->
firSymbolBuilder.typeBuilder.buildKtType(coneKotlinType)
},
firDiagnostic.c,
firDiagnostic.d,
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION.warningFactory) { firDiagnostic ->
InferredTypeVariableIntoEmptyIntersectionWarningImpl(
firDiagnostic.a,
firDiagnostic.b.map { coneKotlinType ->
firSymbolBuilder.typeBuilder.buildKtType(coneKotlinType)
@@ -1579,8 +1579,16 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
abstract val kotlinClass: FqName
}
abstract class InferredTypeVariableIntoEmptyIntersection : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = InferredTypeVariableIntoEmptyIntersection::class
abstract class InferredTypeVariableIntoEmptyIntersectionError : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = InferredTypeVariableIntoEmptyIntersectionError::class
abstract val typeVariableDescription: String
abstract val incompatibleTypes: List<KtType>
abstract val description: String
abstract val causingTypes: String
}
abstract class InferredTypeVariableIntoEmptyIntersectionWarning : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = InferredTypeVariableIntoEmptyIntersectionWarning::class
abstract val typeVariableDescription: String
abstract val incompatibleTypes: List<KtType>
abstract val description: String
@@ -1899,14 +1899,23 @@ internal class PlatformClassMappedToKotlinImpl(
override val token: KtLifetimeToken,
) : KtFirDiagnostic.PlatformClassMappedToKotlin(), KtAbstractFirDiagnostic<PsiElement>
internal class InferredTypeVariableIntoEmptyIntersectionImpl(
internal class InferredTypeVariableIntoEmptyIntersectionErrorImpl(
override val typeVariableDescription: String,
override val incompatibleTypes: List<KtType>,
override val description: String,
override val causingTypes: String,
override val firDiagnostic: KtPsiDiagnostic,
override val token: KtLifetimeToken,
) : KtFirDiagnostic.InferredTypeVariableIntoEmptyIntersection(), KtAbstractFirDiagnostic<PsiElement>
) : KtFirDiagnostic.InferredTypeVariableIntoEmptyIntersectionError(), KtAbstractFirDiagnostic<PsiElement>
internal class InferredTypeVariableIntoEmptyIntersectionWarningImpl(
override val typeVariableDescription: String,
override val incompatibleTypes: List<KtType>,
override val description: String,
override val causingTypes: String,
override val firDiagnostic: KtPsiDiagnostic,
override val token: KtLifetimeToken,
) : KtFirDiagnostic.InferredTypeVariableIntoEmptyIntersectionWarning(), KtAbstractFirDiagnostic<PsiElement>
internal class InferredTypeVariableIntoPossibleEmptyIntersectionImpl(
override val typeVariableDescription: String,