[FIR] Add LOCAL_JVM_RECORD diagnostic
This commit is contained in:
+4
@@ -61,4 +61,8 @@ object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") {
|
||||
}
|
||||
}
|
||||
|
||||
val RECORDS by object : DiagnosticGroup("JVM Records") {
|
||||
val LOCAL_JVM_RECORD by error<PsiElement>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -49,4 +49,7 @@ object FirJvmErrors {
|
||||
// Super
|
||||
val SUPER_CALL_WITH_DEFAULT_PARAMETERS by error1<PsiElement, String>()
|
||||
|
||||
// JVM Records
|
||||
val LOCAL_JVM_RECORD by error0<PsiElement>()
|
||||
|
||||
}
|
||||
|
||||
+5
@@ -19,6 +19,11 @@ object JvmDeclarationCheckers : DeclarationCheckers() {
|
||||
FirStrictfpApplicabilityChecker,
|
||||
)
|
||||
|
||||
override val regularClassCheckers: Set<FirRegularClassChecker>
|
||||
get() = setOf(
|
||||
FirJvmRecordChecker,
|
||||
)
|
||||
|
||||
override val propertyCheckers: Set<FirPropertyChecker>
|
||||
get() = setOf(
|
||||
FirVolatileAnnotationChecker,
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.jvm.checkers.declaration
|
||||
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.FirRegularClassChecker
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.getAnnotationByFqName
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
object FirJvmRecordChecker : FirRegularClassChecker() {
|
||||
|
||||
private val JVM_RECORD_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.JvmRecord")
|
||||
|
||||
override fun check(declaration: FirRegularClass, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val annotationSource = declaration.getAnnotationByFqName(JVM_RECORD_ANNOTATION_FQ_NAME)?.source ?: return
|
||||
|
||||
if (declaration.isLocal) {
|
||||
reporter.reportOn(annotationSource, FirJvmErrors.LOCAL_JVM_RECORD, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -46,7 +46,7 @@ class A10(
|
||||
)
|
||||
|
||||
fun main() {
|
||||
@JvmRecord
|
||||
<!LOCAL_JVM_RECORD!>@JvmRecord<!>
|
||||
class Local
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -3538,4 +3538,10 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJvmErrors.LOCAL_JVM_RECORD) { firDiagnostic ->
|
||||
LocalJvmRecordImpl(
|
||||
firDiagnostic as FirPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -2465,4 +2465,8 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = JvmPackageNameNotSupportedInFilesWithClasses::class
|
||||
}
|
||||
|
||||
abstract class LocalJvmRecord : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = LocalJvmRecord::class
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -3993,3 +3993,10 @@ internal class JvmPackageNameNotSupportedInFilesWithClassesImpl(
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class LocalJvmRecordImpl(
|
||||
firDiagnostic: FirPsiDiagnostic,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.LocalJvmRecord(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user