FIR checker: support DUPLICATE_LABEL_IN_WHEN
Changes from FE1.0: 1. As discussed previously, no expression evaluation happens during this check. 2. FE1.0 doesn't check redundant object comparisons.
This commit is contained in:
committed by
Mikhail Glukhikh
parent
7c6326856b
commit
4915d8dda3
+6
@@ -2933,6 +2933,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.DUPLICATE_LABEL_IN_WHEN) { firDiagnostic ->
|
||||
DuplicateLabelInWhenImpl(
|
||||
firDiagnostic as FirPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirErrors.TYPE_PARAMETER_IS_NOT_AN_EXPRESSION) { firDiagnostic ->
|
||||
TypeParameterIsNotAnExpressionImpl(
|
||||
firSymbolBuilder.classifierBuilder.buildTypeParameterSymbol(firDiagnostic.a.fir),
|
||||
|
||||
+4
@@ -2050,6 +2050,10 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = CommaInWhenConditionWithoutArgument::class
|
||||
}
|
||||
|
||||
abstract class DuplicateLabelInWhen : KtFirDiagnostic<KtElement>() {
|
||||
override val diagnosticClass get() = DuplicateLabelInWhen::class
|
||||
}
|
||||
|
||||
abstract class TypeParameterIsNotAnExpression : KtFirDiagnostic<KtSimpleNameExpression>() {
|
||||
override val diagnosticClass get() = TypeParameterIsNotAnExpression::class
|
||||
abstract val typeParameter: KtTypeParameterSymbol
|
||||
|
||||
+7
@@ -3305,6 +3305,13 @@ internal class CommaInWhenConditionWithoutArgumentImpl(
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class DuplicateLabelInWhenImpl(
|
||||
firDiagnostic: FirPsiDiagnostic,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.DuplicateLabelInWhen(), KtAbstractFirDiagnostic<KtElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class TypeParameterIsNotAnExpressionImpl(
|
||||
override val typeParameter: KtTypeParameterSymbol,
|
||||
firDiagnostic: FirPsiDiagnostic,
|
||||
|
||||
Reference in New Issue
Block a user