K2: report JvmMultifileClass+JvmSynthetic error in JVM backend

Specifically, the case when not all parts of a multifile class are
annotated with `@JvmSynthetic`. Report the error on the
`@JvmMultifileClass` annotation instead of the package directive,
because the latter is difficult to find via IR. This fixes the test
FirLightTreeDiagnosticsTestWithJvmIrBackendGenerated.MultifileClasses.testJvmSynthetic.

 #KT-59586
This commit is contained in:
Alexander Udalov
2023-07-24 17:24:35 +02:00
parent 96ddd9bbf3
commit 6069aaee9c
3 changed files with 17 additions and 10 deletions
@@ -37,6 +37,8 @@ object JvmBackendErrors {
val INLINE_CALL_CYCLE by error1<PsiElement, Name>()
val NOT_ALL_MULTIFILE_CLASS_PARTS_ARE_JVM_SYNTHETIC by error0<PsiElement>()
init {
RootDiagnosticRendererFactory.registerFactory(KtDefaultJvmErrorMessages)
}
@@ -72,5 +74,9 @@ object KtDefaultJvmErrorMessages : BaseDiagnosticRendererFactory() {
map.put(JvmBackendErrors.SCRIPT_CAPTURING_ENUM_ENTRY, "Enum entry {0} captures the script class instance. Try to use class or anonymous object instead", STRING)
map.put(JvmBackendErrors.INLINE_CALL_CYCLE, "The ''{0}'' invocation is a part of inline cycle", NAME)
map.put(
JvmBackendErrors.NOT_ALL_MULTIFILE_CLASS_PARTS_ARE_JVM_SYNTHETIC,
"All of multi-file class parts should be annotated with @JvmSynthetic if at least one of them is"
)
}
}