[JS IR] Run diagnostics by IR before the klib serialization

Implement an infrastructure for checking IR before JS klib serialization.
Implement the EXPORTING_JS_NAME_CLASH and EXPORTING_JS_NAME_CLASH_ES checks.

^KT-61710 Fixed
This commit is contained in:
Alexander Korepanov
2023-09-07 22:08:22 +02:00
parent 13bd627bfa
commit 522952db1f
24 changed files with 385 additions and 87 deletions
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.js.klib.generateIrForKlibSerialization
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.diagnostics.DiagnosticReporterFactory
import org.jetbrains.kotlin.ir.backend.js.*
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.JsGenerationGranularity
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
@@ -108,13 +109,15 @@ abstract class IrAbstractInvalidationTest(
val metadataSerializer =
KlibMetadataIncrementalSerializer(configuration, sourceModule.project, sourceModule.jsFrontEndResult.hasErrors)
val diagnosticReporter = DiagnosticReporterFactory.createPendingReporter()
generateKLib(
sourceModule,
outputKlibFile.canonicalPath,
nopack = false,
jsOutputName = moduleName,
icData = icData,
moduleFragment = moduleFragment
moduleFragment = moduleFragment,
diagnosticReporter = diagnosticReporter
) { file ->
metadataSerializer.serializeScope(file, sourceModule.jsFrontEndResult.bindingContext, moduleFragment.descriptor)
}