K2: report DUPLICATE_CLASS_NAMES error in JVM backend
It was already reported in the K2+PSI mode, but not LT because BuilderFactoryForDuplicateClassNameDiagnostics relied on PSI, and did not do anything if PSI was missing. No tests were added because it fixes the already existing test `compiler/testData/cli/jvm/fileClassClashMultipleFiles` after the project is migrated to 2.0. #KT-59586
This commit is contained in:
committed by
Space Team
parent
84bf411cc3
commit
2823fff63d
+4
@@ -39,6 +39,8 @@ object JvmBackendErrors {
|
||||
|
||||
val NOT_ALL_MULTIFILE_CLASS_PARTS_ARE_JVM_SYNTHETIC by error0<PsiElement>()
|
||||
|
||||
val DUPLICATE_CLASS_NAMES by error2<PsiElement, String, String>()
|
||||
|
||||
init {
|
||||
RootDiagnosticRendererFactory.registerFactory(KtDefaultJvmErrorMessages)
|
||||
}
|
||||
@@ -78,5 +80,7 @@ object KtDefaultJvmErrorMessages : BaseDiagnosticRendererFactory() {
|
||||
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"
|
||||
)
|
||||
|
||||
map.put(JvmBackendErrors.DUPLICATE_CLASS_NAMES, "Duplicate JVM class name ''{0}'' generated from: {1}", STRING, STRING)
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -25,6 +25,11 @@ open class JvmDeclarationOrigin(
|
||||
val descriptor: DeclarationDescriptor?,
|
||||
val parametersForJvmOverload: List<KtParameter?>? = null
|
||||
) {
|
||||
// This property is used to get the original element in the sources, from which this declaration was generated.
|
||||
// In the old JVM backend, it is just the PSI element. In JVM IR, it is the original IR element (before any deep copy).
|
||||
open val originalSourceElement: Any?
|
||||
get() = element
|
||||
|
||||
override fun toString(): String =
|
||||
if (this == NO_ORIGIN) "NO_ORIGIN" else "origin=$originKind element=${element?.javaClass?.simpleName} descriptor=$descriptor"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user