From 61e957fc002a5e9cbb9be5f79e54c406db49b9c6 Mon Sep 17 00:00:00 2001 From: Sergej Jaskiewicz Date: Tue, 9 Jan 2024 17:56:32 +0100 Subject: [PATCH] [JS] Mute the EXPORTING_JS_NAME_CLASH_ES diagnostic in TS export tests This diagnostic started to appear after 51c920af01e3d583c552224a529abe1f6e5fcf16. --- .../jetbrains/kotlin/test/backend/handlers/HandlerUtils.kt | 7 +++++-- .../test/backend/handlers/JvmBackendDiagnosticsHandler.kt | 3 +++ .../kotlin/test/backend/ir/IrDiagnosticsHandler.kt | 3 +++ .../namespaces-in-exported-file/namespaces.kt | 6 ++++++ .../testData/typescript-export/namespaces/namespaces.kt | 6 ++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/HandlerUtils.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/HandlerUtils.kt index b6d703bb7ba..da741fd0140 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/HandlerUtils.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/HandlerUtils.kt @@ -33,14 +33,17 @@ fun BinaryArtifactHandler<*>.reportKtDiagnostics(module: TestModule, ktDiagnosti val lightTreeEnabled = firParser == FirParser.LightTree val processedModules = mutableSetOf() + val diagnosticsService = testServices.diagnosticsService fun processModule(module: TestModule) { if (!processedModules.add(module)) return for (testFile in module.files) { val ktDiagnostics = ktDiagnosticReporter.diagnosticsByFilePath["/${testFile.name}"] ?: continue ktDiagnostics.forEach { - val metaInfos = it.toMetaInfos(module, testFile, globalMetadataInfoHandler, lightTreeEnabled, lightTreeComparingModeEnabled) - globalMetadataInfoHandler.addMetadataInfosForFile(testFile, metaInfos) + if (diagnosticsService.shouldRenderDiagnostic(module, it.factoryName, it.severity)) { + val metaInfos = it.toMetaInfos(module, testFile, globalMetadataInfoHandler, lightTreeEnabled, lightTreeComparingModeEnabled) + globalMetadataInfoHandler.addMetadataInfosForFile(testFile, metaInfos) + } } } for ((moduleName, _, _) in module.dependsOnDependencies) { diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBackendDiagnosticsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBackendDiagnosticsHandler.kt index f0f7a401f9c..5654156a94c 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBackendDiagnosticsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/handlers/JvmBackendDiagnosticsHandler.kt @@ -17,6 +17,9 @@ import org.junit.jupiter.api.fail class JvmBackendDiagnosticsHandler(testServices: TestServices) : JvmBinaryArtifactHandler(testServices) { private val reporter = ClassicDiagnosticReporter(testServices) + override val additionalServices: List + get() = listOf(service(::DiagnosticsService)) + override fun processModule(module: TestModule, info: BinaryArtifacts.Jvm) { reportDiagnostics(module, info) reportKtDiagnostics(module, info) diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/IrDiagnosticsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/IrDiagnosticsHandler.kt index bfc7857ffa7..068af149048 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/IrDiagnosticsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/IrDiagnosticsHandler.kt @@ -22,6 +22,9 @@ class IrDiagnosticsHandler(testServices: TestServices) : AbstractIrHandler(testS private val diagnosticsService: DiagnosticsService get() = testServices.diagnosticsService + override val additionalServices: List + get() = listOf(service(::DiagnosticsService)) + private val fullDiagnosticsRenderer = FullDiagnosticsRenderer(DiagnosticsDirectives.RENDER_IR_DIAGNOSTICS_FULL_TEXT) override fun processModule(module: TestModule, info: IrBackendInput) { diff --git a/js/js.translator/testData/typescript-export/namespaces-in-exported-file/namespaces.kt b/js/js.translator/testData/typescript-export/namespaces-in-exported-file/namespaces.kt index 4ddf2efcedb..00fc206fea7 100644 --- a/js/js.translator/testData/typescript-export/namespaces-in-exported-file/namespaces.kt +++ b/js/js.translator/testData/typescript-export/namespaces-in-exported-file/namespaces.kt @@ -6,6 +6,12 @@ // SKIP_NODE_JS // INFER_MAIN_MODULE +// DIAGNOSTICS: -EXPORTING_JS_NAME_CLASH_ES +// ^ This warning only concernes the ES6 mode, but since it's reported during KLIB serialization, the module system is unknown at that +// point. Additionally, the same KLIB can be used for building JS in different module systems. Therefore, the warning is always written, +// regardless of the project's module system. + + // MODULE: JS_TESTS // FILE: file1.kt diff --git a/js/js.translator/testData/typescript-export/namespaces/namespaces.kt b/js/js.translator/testData/typescript-export/namespaces/namespaces.kt index d7ae45ba160..3d86685f94d 100644 --- a/js/js.translator/testData/typescript-export/namespaces/namespaces.kt +++ b/js/js.translator/testData/typescript-export/namespaces/namespaces.kt @@ -4,6 +4,12 @@ // SKIP_NODE_JS // INFER_MAIN_MODULE +// DIAGNOSTICS: -EXPORTING_JS_NAME_CLASH_ES +// ^ This warning only concernes the ES6 mode, but since it's reported during KLIB serialization, the module system is unknown at that +// point. Additionally, the same KLIB can be used for building JS in different module systems. Therefore, the warning is always written, +// regardless of the project's module system. + + // MODULE: JS_TESTS // FILE: file1.kt