[Test] Use IrPluginContext for searching declarations for DUMP_EXTERNAL_CLASS check
This commit is contained in:
committed by
Space Team
parent
e7f6482857
commit
5d6cb2b691
+27
-15
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.backend.jvm
|
||||
|
||||
import org.jetbrains.kotlin.analyzer.hasJdkCapability
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContextImpl
|
||||
import org.jetbrains.kotlin.backend.common.phaser.CompilerPhase
|
||||
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
|
||||
@@ -90,6 +91,7 @@ open class JvmIrCodegenFactory(
|
||||
val irProviders: List<IrProvider>,
|
||||
val extensions: JvmGeneratorExtensions,
|
||||
val backendExtension: JvmBackendExtension,
|
||||
val pluginContext: IrPluginContext,
|
||||
val notifyCodegenStart: () -> Unit
|
||||
) : CodegenFactory.BackendInput
|
||||
|
||||
@@ -163,20 +165,19 @@ open class JvmIrCodegenFactory(
|
||||
|
||||
SourceDeclarationsPreprocessor(psi2irContext).run(input.files)
|
||||
|
||||
// The plugin context contains unbound symbols right after construction and has to be
|
||||
// instantiated before we resolve unbound symbols and invoke any postprocessing steps.
|
||||
val pluginContext = IrPluginContextImpl(
|
||||
psi2irContext.moduleDescriptor,
|
||||
psi2irContext.bindingContext,
|
||||
psi2irContext.languageVersionSettings,
|
||||
symbolTable,
|
||||
psi2irContext.typeTranslator,
|
||||
psi2irContext.irBuiltIns,
|
||||
irLinker,
|
||||
messageLogger
|
||||
)
|
||||
if (pluginExtensions.isNotEmpty() && psi2irContext.configuration.generateBodies) {
|
||||
// The plugin context contains unbound symbols right after construction and has to be
|
||||
// instantiated before we resolve unbound symbols and invoke any postprocessing steps.
|
||||
val pluginContext = IrPluginContextImpl(
|
||||
psi2irContext.moduleDescriptor,
|
||||
psi2irContext.bindingContext,
|
||||
psi2irContext.languageVersionSettings,
|
||||
symbolTable,
|
||||
psi2irContext.typeTranslator,
|
||||
psi2irContext.irBuiltIns,
|
||||
irLinker,
|
||||
messageLogger
|
||||
)
|
||||
|
||||
for (extension in pluginExtensions) {
|
||||
psi2ir.addPostprocessingStep { module ->
|
||||
val old = stubGenerator.unboundSymbolGeneration
|
||||
@@ -243,6 +244,7 @@ open class JvmIrCodegenFactory(
|
||||
irProviders,
|
||||
jvmGeneratorExtensions,
|
||||
JvmBackendExtension.Default,
|
||||
pluginContext,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -272,7 +274,7 @@ open class JvmIrCodegenFactory(
|
||||
}
|
||||
|
||||
override fun invokeLowerings(state: GenerationState, input: CodegenFactory.BackendInput): CodegenFactory.CodegenInput {
|
||||
val (irModuleFragment, symbolTable, customPhaseConfig, irProviders, extensions, backendExtension, notifyCodegenStart) =
|
||||
val (irModuleFragment, symbolTable, customPhaseConfig, irProviders, extensions, backendExtension, _, notifyCodegenStart) =
|
||||
input as JvmIrBackendInput
|
||||
val irSerializer = if (
|
||||
state.configuration.get(JVMConfigurationKeys.SERIALIZE_IR, JvmSerializeIrMode.NONE) != JvmSerializeIrMode.NONE
|
||||
@@ -326,11 +328,21 @@ open class JvmIrCodegenFactory(
|
||||
irProviders: List<IrProvider>,
|
||||
extensions: JvmGeneratorExtensions,
|
||||
backendExtension: JvmBackendExtension,
|
||||
irPluginContext: IrPluginContext,
|
||||
notifyCodegenStart: () -> Unit = {}
|
||||
) {
|
||||
generateModule(
|
||||
state,
|
||||
JvmIrBackendInput(irModuleFragment, symbolTable, phaseConfig, irProviders, extensions, backendExtension, notifyCodegenStart)
|
||||
JvmIrBackendInput(
|
||||
irModuleFragment,
|
||||
symbolTable,
|
||||
phaseConfig,
|
||||
irProviders,
|
||||
extensions,
|
||||
backendExtension,
|
||||
irPluginContext,
|
||||
notifyCodegenStart
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ import org.jetbrains.kotlin.analyzer.AbstractAnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.analyzer.CompilationErrorException
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
|
||||
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContextImpl
|
||||
import org.jetbrains.kotlin.backend.common.lower.ExpectDeclarationRemover
|
||||
import org.jetbrains.kotlin.backend.common.overrides.FakeOverrideChecker
|
||||
import org.jetbrains.kotlin.backend.common.serialization.*
|
||||
import org.jetbrains.kotlin.backend.common.serialization.linkerissues.checkNoUnboundSymbols
|
||||
@@ -347,7 +347,7 @@ fun getIrModuleInfoForSourceFiles(
|
||||
true
|
||||
)
|
||||
|
||||
val moduleFragment = psi2IrContext.generateModuleFragmentWithPlugins(project, files, irLinker, messageLogger)
|
||||
val (moduleFragment, _) = psi2IrContext.generateModuleFragmentWithPlugins(project, files, irLinker, messageLogger)
|
||||
|
||||
// TODO: not sure whether this check should be enabled by default. Add configuration key for it.
|
||||
val mangleChecker = ManglerChecker(JsManglerIr, Ir2DescriptorManglerAdapter(JsManglerDesc))
|
||||
@@ -400,23 +400,22 @@ fun GeneratorContext.generateModuleFragmentWithPlugins(
|
||||
messageLogger: IrMessageLogger,
|
||||
expectDescriptorToSymbol: MutableMap<DeclarationDescriptor, IrSymbol>? = null,
|
||||
stubGenerator: DeclarationStubGenerator? = null
|
||||
): IrModuleFragment {
|
||||
): Pair<IrModuleFragment, IrPluginContext> {
|
||||
val psi2Ir = Psi2IrTranslator(languageVersionSettings, configuration, messageLogger::checkNoUnboundSymbols)
|
||||
val extensions = IrGenerationExtension.getInstances(project)
|
||||
|
||||
// plugin context should be instantiated before postprocessing steps
|
||||
val pluginContext = IrPluginContextImpl(
|
||||
moduleDescriptor,
|
||||
bindingContext,
|
||||
languageVersionSettings,
|
||||
symbolTable,
|
||||
typeTranslator,
|
||||
irBuiltIns,
|
||||
linker = irLinker,
|
||||
messageLogger
|
||||
)
|
||||
if (extensions.isNotEmpty()) {
|
||||
// plugin context should be instantiated before postprocessing steps
|
||||
val pluginContext = IrPluginContextImpl(
|
||||
moduleDescriptor,
|
||||
bindingContext,
|
||||
languageVersionSettings,
|
||||
symbolTable,
|
||||
typeTranslator,
|
||||
irBuiltIns,
|
||||
linker = irLinker,
|
||||
messageLogger
|
||||
)
|
||||
|
||||
for (extension in extensions) {
|
||||
psi2Ir.addPostprocessingStep { module ->
|
||||
val old = stubGenerator?.unboundSymbolGeneration
|
||||
@@ -437,7 +436,7 @@ fun GeneratorContext.generateModuleFragmentWithPlugins(
|
||||
listOf(stubGenerator ?: irLinker),
|
||||
extensions,
|
||||
expectDescriptorToSymbol
|
||||
)
|
||||
) to pluginContext
|
||||
}
|
||||
|
||||
private fun createBuiltIns(storageManager: StorageManager) = object : KotlinBuiltIns(storageManager) {}
|
||||
|
||||
Reference in New Issue
Block a user