FIR: introduce three diagnostics for const val
This commit is contained in:
committed by
Mikhail Glukhikh
parent
cc106085e2
commit
334d0a8b5a
+19
@@ -1430,6 +1430,25 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.TYPE_CANT_BE_USED_FOR_CONST_VAL) { firDiagnostic ->
|
||||
TypeCantBeUsedForConstValImpl(
|
||||
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.CONST_VAL_WITHOUT_INITIALIZER) { firDiagnostic ->
|
||||
ConstValWithoutInitializerImpl(
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.CONST_VAL_WITH_NON_CONST_INITIALIZER) { firDiagnostic ->
|
||||
ConstValWithNonConstInitializerImpl(
|
||||
firDiagnostic as FirPsiDiagnostic<*>,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.WRONG_SETTER_PARAMETER_TYPE) { firDiagnostic ->
|
||||
WrongSetterParameterTypeImpl(
|
||||
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
|
||||
|
||||
+13
@@ -1011,6 +1011,19 @@ sealed class KtFirDiagnostic<PSI: PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = ConstValWithDelegate::class
|
||||
}
|
||||
|
||||
abstract class TypeCantBeUsedForConstVal : KtFirDiagnostic<KtProperty>() {
|
||||
override val diagnosticClass get() = TypeCantBeUsedForConstVal::class
|
||||
abstract val constValType: KtType
|
||||
}
|
||||
|
||||
abstract class ConstValWithoutInitializer : KtFirDiagnostic<KtProperty>() {
|
||||
override val diagnosticClass get() = ConstValWithoutInitializer::class
|
||||
}
|
||||
|
||||
abstract class ConstValWithNonConstInitializer : KtFirDiagnostic<KtExpression>() {
|
||||
override val diagnosticClass get() = ConstValWithNonConstInitializer::class
|
||||
}
|
||||
|
||||
abstract class WrongSetterParameterType : KtFirDiagnostic<KtTypeReference>() {
|
||||
override val diagnosticClass get() = WrongSetterParameterType::class
|
||||
abstract val expectedType: KtType
|
||||
|
||||
+22
@@ -1636,6 +1636,28 @@ internal class ConstValWithDelegateImpl(
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class TypeCantBeUsedForConstValImpl(
|
||||
override val constValType: KtType,
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.TypeCantBeUsedForConstVal(), KtAbstractFirDiagnostic<KtProperty> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class ConstValWithoutInitializerImpl(
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.ConstValWithoutInitializer(), KtAbstractFirDiagnostic<KtProperty> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class ConstValWithNonConstInitializerImpl(
|
||||
firDiagnostic: FirPsiDiagnostic<*>,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.ConstValWithNonConstInitializer(), KtAbstractFirDiagnostic<KtExpression> {
|
||||
override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class WrongSetterParameterTypeImpl(
|
||||
override val expectedType: KtType,
|
||||
override val actualType: KtType,
|
||||
|
||||
Reference in New Issue
Block a user