[FIR] Add more type params checks

VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED
BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED
This commit is contained in:
Andrey Zinovyev
2021-04-11 19:33:12 +03:00
committed by TeamCityServer
parent fb1b253d1e
commit 14fe570a00
15 changed files with 128 additions and 42 deletions
@@ -986,6 +986,18 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED) { firDiagnostic ->
BoundOnTypeAliasParameterNotAllowedImpl(
firDiagnostic as FirPsiDiagnostic<*>,
token,
)
}
add(FirErrors.REIFIED_TYPE_PARAMETER_NO_INLINE) { firDiagnostic ->
ReifiedTypeParameterNoInlineImpl(
firDiagnostic as FirPsiDiagnostic<*>,
token,
)
}
add(FirErrors.RETURN_TYPE_MISMATCH) { firDiagnostic ->
ReturnTypeMismatchImpl(
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
@@ -701,6 +701,14 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
abstract val typeParametersOwner: KtSymbol
}
abstract class BoundOnTypeAliasParameterNotAllowed : KtFirDiagnostic<KtTypeReference>() {
override val diagnosticClass get() = BoundOnTypeAliasParameterNotAllowed::class
}
abstract class ReifiedTypeParameterNoInline : KtFirDiagnostic<PsiElement>() {
override val diagnosticClass get() = ReifiedTypeParameterNoInline::class
}
abstract class ReturnTypeMismatch : KtFirDiagnostic<KtExpression>() {
override val diagnosticClass get() = ReturnTypeMismatch::class
abstract val expected: KtType
@@ -1131,6 +1131,20 @@ internal class NameInConstraintIsNotATypeParameterImpl(
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class BoundOnTypeAliasParameterNotAllowedImpl(
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,
) : KtFirDiagnostic.BoundOnTypeAliasParameterNotAllowed(), KtAbstractFirDiagnostic<KtTypeReference> {
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class ReifiedTypeParameterNoInlineImpl(
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,
) : KtFirDiagnostic.ReifiedTypeParameterNoInline(), KtAbstractFirDiagnostic<PsiElement> {
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class ReturnTypeMismatchImpl(
override val expected: KtType,
override val actual: KtType,