[FIR] Add CYCLIC_GENERIC_UPPER_BOUND check

This commit is contained in:
Andrey Zinovyev
2021-04-12 18:53:09 +03:00
committed by TeamCityServer
parent 03215f4e0a
commit 2b8c22c08a
27 changed files with 144 additions and 35 deletions
@@ -1018,6 +1018,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.CYCLIC_GENERIC_UPPER_BOUND) { firDiagnostic ->
CyclicGenericUpperBoundImpl(
firDiagnostic as FirPsiDiagnostic<*>,
token,
)
}
add(FirErrors.EXTENSION_IN_CLASS_REFERENCE_NOT_ALLOWED) { firDiagnostic ->
ExtensionInClassReferenceNotAllowedImpl(
firSymbolBuilder.callableBuilder.buildCallableSymbol(firDiagnostic.a as FirCallableDeclaration),
@@ -723,6 +723,10 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
abstract val actual: KtType
}
abstract class CyclicGenericUpperBound : KtFirDiagnostic<KtTypeParameter>() {
override val diagnosticClass get() = CyclicGenericUpperBound::class
}
abstract class ExtensionInClassReferenceNotAllowed : KtFirDiagnostic<KtExpression>() {
override val diagnosticClass get() = ExtensionInClassReferenceNotAllowed::class
abstract val referencedDeclaration: KtCallableSymbol
@@ -1168,6 +1168,13 @@ internal class ReturnTypeMismatchImpl(
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class CyclicGenericUpperBoundImpl(
firDiagnostic: FirPsiDiagnostic<*>,
override val token: ValidityToken,
) : KtFirDiagnostic.CyclicGenericUpperBound(), KtAbstractFirDiagnostic<KtTypeParameter> {
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
}
internal class ExtensionInClassReferenceNotAllowedImpl(
override val referencedDeclaration: KtCallableSymbol,
firDiagnostic: FirPsiDiagnostic<*>,