FIR checker: report NOT_A_FUNCTION_LABEL

This commit is contained in:
Tianyu Geng
2021-09-22 18:37:23 -07:00
committed by TeamCityServer
parent ab9a23cbfa
commit 5c716ea979
12 changed files with 52 additions and 23 deletions
@@ -3404,6 +3404,12 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
token,
)
}
add(FirErrors.NOT_A_FUNCTION_LABEL) { firDiagnostic ->
NotAFunctionLabelImpl(
firDiagnostic as FirPsiDiagnostic,
token,
)
}
add(FirErrors.RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY) { firDiagnostic ->
ReturnInFunctionWithExpressionBodyImpl(
firDiagnostic as FirPsiDiagnostic,
@@ -2371,6 +2371,10 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
override val diagnosticClass get() = ReturnNotAllowed::class
}
abstract class NotAFunctionLabel : KtFirDiagnostic<KtReturnExpression>() {
override val diagnosticClass get() = NotAFunctionLabel::class
}
abstract class ReturnInFunctionWithExpressionBody : KtFirDiagnostic<KtReturnExpression>() {
override val diagnosticClass get() = ReturnInFunctionWithExpressionBody::class
}
@@ -2859,6 +2859,11 @@ internal class ReturnNotAllowedImpl(
override val token: ValidityToken,
) : KtFirDiagnostic.ReturnNotAllowed(), KtAbstractFirDiagnostic<KtReturnExpression>
internal class NotAFunctionLabelImpl(
override val firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.NotAFunctionLabel(), KtAbstractFirDiagnostic<KtReturnExpression>
internal class ReturnInFunctionWithExpressionBodyImpl(
override val firDiagnostic: FirPsiDiagnostic,
override val token: ValidityToken,