[FIR] Add JVM_RECORD_NOT_LAST_VARARG_PARAMETER diagnostic
This commit is contained in:
+1
@@ -68,6 +68,7 @@ object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") {
|
||||
val JVM_RECORD_WITHOUT_PRIMARY_CONSTRUCTOR_PARAMETERS by error<PsiElement>()
|
||||
val NON_DATA_CLASS_JVM_RECORD by error<PsiElement>()
|
||||
val JVM_RECORD_NOT_VAL_PARAMETER by error<PsiElement>()
|
||||
val JVM_RECORD_NOT_LAST_VARARG_PARAMETER by error<PsiElement>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -57,5 +57,6 @@ object FirJvmErrors {
|
||||
val JVM_RECORD_WITHOUT_PRIMARY_CONSTRUCTOR_PARAMETERS by error0<PsiElement>()
|
||||
val NON_DATA_CLASS_JVM_RECORD by error0<PsiElement>()
|
||||
val JVM_RECORD_NOT_VAL_PARAMETER by error0<PsiElement>()
|
||||
val JVM_RECORD_NOT_LAST_VARARG_PARAMETER by error0<PsiElement>()
|
||||
|
||||
}
|
||||
|
||||
+10
-3
@@ -58,9 +58,16 @@ object FirJvmRecordChecker : FirRegularClassChecker() {
|
||||
return
|
||||
}
|
||||
|
||||
if (declaration.primaryConstructor?.valueParameters?.isEmpty() == true) {
|
||||
reporter.reportOn(annotationSource, FirJvmErrors.JVM_RECORD_WITHOUT_PRIMARY_CONSTRUCTOR_PARAMETERS, context)
|
||||
return
|
||||
declaration.primaryConstructor?.valueParameters?.let { params ->
|
||||
if (params.isEmpty()) {
|
||||
reporter.reportOn(annotationSource, FirJvmErrors.JVM_RECORD_WITHOUT_PRIMARY_CONSTRUCTOR_PARAMETERS, context)
|
||||
return
|
||||
}
|
||||
params.dropLast(1).forEach { param ->
|
||||
if (param.isVararg) {
|
||||
reporter.reportOn(param.source, FirJvmErrors.JVM_RECORD_NOT_LAST_VARARG_PARAMETER, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declaration.declarations.forEach { decl ->
|
||||
|
||||
+6
@@ -3574,4 +3574,10 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJvmErrors.JVM_RECORD_NOT_LAST_VARARG_PARAMETER) { firDiagnostic ->
|
||||
JvmRecordNotLastVarargParameterImpl(
|
||||
firDiagnostic as FirPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -2489,4 +2489,8 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = JvmRecordNotValParameter::class
|
||||
}
|
||||
|
||||
abstract class JvmRecordNotLastVarargParameter : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = JvmRecordNotLastVarargParameter::class
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -4035,3 +4035,10 @@ internal class JvmRecordNotValParameterImpl(
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class JvmRecordNotLastVarargParameterImpl(
|
||||
firDiagnostic: FirPsiDiagnostic,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.JvmRecordNotLastVarargParameter(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user