[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 ->
|
||||
|
||||
Reference in New Issue
Block a user