[FIR] Add DELEGATION_BY_IN_JVM_RECORD diagnostic
This commit is contained in:
+1
@@ -71,6 +71,7 @@ object JVM_DIAGNOSTICS_LIST : DiagnosticList("FirJvmErrors") {
|
||||
val JVM_RECORD_NOT_LAST_VARARG_PARAMETER by error<PsiElement>()
|
||||
val INNER_JVM_RECORD by error<PsiElement>(PositioningStrategy.INNER_MODIFIER)
|
||||
val FIELD_IN_JVM_RECORD by error<PsiElement>()
|
||||
val DELEGATION_BY_IN_JVM_RECORD by error<PsiElement>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -60,5 +60,6 @@ object FirJvmErrors {
|
||||
val JVM_RECORD_NOT_LAST_VARARG_PARAMETER by error0<PsiElement>()
|
||||
val INNER_JVM_RECORD by error0<PsiElement>(SourceElementPositioningStrategies.INNER_MODIFIER)
|
||||
val FIELD_IN_JVM_RECORD by error0<PsiElement>()
|
||||
val DELEGATION_BY_IN_JVM_RECORD by error0<PsiElement>()
|
||||
|
||||
}
|
||||
|
||||
+3
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.declarations.FirField
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.getAnnotationByFqName
|
||||
@@ -83,6 +84,8 @@ object FirJvmRecordChecker : FirRegularClassChecker() {
|
||||
} else if (!fromConstructor && (decl.hasBackingField || decl.delegateFieldSymbol != null)) {
|
||||
reporter.reportOn(decl.source, FirJvmErrors.FIELD_IN_JVM_RECORD, context)
|
||||
}
|
||||
} else if (decl is FirField && decl.isSynthetic) {
|
||||
reporter.reportOn(decl.source, FirJvmErrors.DELEGATION_BY_IN_JVM_RECORD, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ interface I
|
||||
val i: I = object : I {}
|
||||
|
||||
@JvmRecord
|
||||
data class MyRec1(val name: String) : I by i
|
||||
data class MyRec1(val name: String) : I by <!DELEGATION_BY_IN_JVM_RECORD!>i<!>
|
||||
|
||||
@JvmRecord
|
||||
data class MyRec2(val name: String) {
|
||||
|
||||
+6
@@ -3592,4 +3592,10 @@ internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConvert
|
||||
token,
|
||||
)
|
||||
}
|
||||
add(FirJvmErrors.DELEGATION_BY_IN_JVM_RECORD) { firDiagnostic ->
|
||||
DelegationByInJvmRecordImpl(
|
||||
firDiagnostic as FirPsiDiagnostic,
|
||||
token,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -2501,4 +2501,8 @@ sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI> {
|
||||
override val diagnosticClass get() = FieldInJvmRecord::class
|
||||
}
|
||||
|
||||
abstract class DelegationByInJvmRecord : KtFirDiagnostic<PsiElement>() {
|
||||
override val diagnosticClass get() = DelegationByInJvmRecord::class
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -4056,3 +4056,10 @@ internal class FieldInJvmRecordImpl(
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
internal class DelegationByInJvmRecordImpl(
|
||||
firDiagnostic: FirPsiDiagnostic,
|
||||
override val token: ValidityToken,
|
||||
) : KtFirDiagnostic.DelegationByInJvmRecord(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
override val firDiagnostic: FirPsiDiagnostic by weakRef(firDiagnostic)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user