FIR checker: pass expected array type in ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION

This is needed by the IDE quickfix to generate the correct `arrayOf` (or
`intArrayOf`, etc`) wrapper call.
This commit is contained in:
Tianyu Geng
2021-10-20 03:39:18 +03:00
committed by teamcity
parent 9f062df258
commit b48870c11f
7 changed files with 33 additions and 11 deletions
@@ -1475,12 +1475,14 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
}
add(FirErrors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION.errorFactory) { firDiagnostic ->
AssigningSingleElementToVarargInNamedFormFunctionErrorImpl(
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
firDiagnostic as KtPsiDiagnostic,
token,
)
}
add(FirErrors.ASSIGNING_SINGLE_ELEMENT_TO_VARARG_IN_NAMED_FORM_FUNCTION.warningFactory) { firDiagnostic ->
AssigningSingleElementToVarargInNamedFormFunctionWarningImpl(
firSymbolBuilder.typeBuilder.buildKtType(firDiagnostic.a),
firDiagnostic as KtPsiDiagnostic,
token,
)
@@ -1062,10 +1062,12 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
abstract class AssigningSingleElementToVarargInNamedFormFunctionError : KtFirDiagnostic<KtExpression>() {
override val diagnosticClass get() = AssigningSingleElementToVarargInNamedFormFunctionError::class
abstract val expectedArrayType: KtType
}
abstract class AssigningSingleElementToVarargInNamedFormFunctionWarning : KtFirDiagnostic<KtExpression>() {
override val diagnosticClass get() = AssigningSingleElementToVarargInNamedFormFunctionWarning::class
abstract val expectedArrayType: KtType
}
abstract class AssigningSingleElementToVarargInNamedFormAnnotationError : KtFirDiagnostic<KtExpression>() {
@@ -1270,11 +1270,13 @@ internal class SpreadOfNullableImpl(
) : KtFirDiagnostic.SpreadOfNullable(), KtAbstractFirDiagnostic<PsiElement>
internal class AssigningSingleElementToVarargInNamedFormFunctionErrorImpl(
override val expectedArrayType: KtType,
override val firDiagnostic: KtPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.AssigningSingleElementToVarargInNamedFormFunctionError(), KtAbstractFirDiagnostic<KtExpression>
internal class AssigningSingleElementToVarargInNamedFormFunctionWarningImpl(
override val expectedArrayType: KtType,
override val firDiagnostic: KtPsiDiagnostic,
override val token: ValidityToken,
) : KtFirDiagnostic.AssigningSingleElementToVarargInNamedFormFunctionWarning(), KtAbstractFirDiagnostic<KtExpression>