K2 Tests. Do not use the TopDownAnalyzerFacadeForJVM to create module descriptor
In fact, TopDownAnalyzerFacadeForJVM.createContainer initializes the whole K1 frontend. While it is only used to create a module descriptor for GenerationState.Builder, in real K2 compiler the module descriptor would be created via irModuleFragment. See org.jetbrains.kotlin.cli.jvm.compiler.pipeline.CompilerPipelineKt.generateCodeFromIr
This commit is contained in:
committed by
Space Team
parent
023cce1fab
commit
f4c7f513ef
+1
-8
@@ -73,14 +73,7 @@ class Fir2IrJvmResultsConverter(
|
|||||||
// Create and initialize the module and its dependencies
|
// Create and initialize the module and its dependencies
|
||||||
val project = compilerConfigurationProvider.getProject(module)
|
val project = compilerConfigurationProvider.getProject(module)
|
||||||
// TODO: handle fir from light tree
|
// TODO: handle fir from light tree
|
||||||
val ktFiles = inputArtifact.mainFirFiles.mapNotNull { it.value.psi as KtFile? }
|
|
||||||
val sourceFiles = inputArtifact.mainFirFiles.mapNotNull { it.value.sourceFile }
|
val sourceFiles = inputArtifact.mainFirFiles.mapNotNull { it.value.sourceFile }
|
||||||
val container = TopDownAnalyzerFacadeForJVM.createContainer(
|
|
||||||
project, ktFiles, NoScopeRecordCliBindingTrace(), configuration,
|
|
||||||
compilerConfigurationProvider.getPackagePartProviderFactory(module),
|
|
||||||
::FileBasedDeclarationProviderFactory, CompilerEnvironment,
|
|
||||||
TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, ktFiles), emptyList()
|
|
||||||
)
|
|
||||||
|
|
||||||
val phaseConfig = configuration.get(CLIConfigurationKeys.PHASE_CONFIG)
|
val phaseConfig = configuration.get(CLIConfigurationKeys.PHASE_CONFIG)
|
||||||
|
|
||||||
@@ -128,7 +121,7 @@ class Fir2IrJvmResultsConverter(
|
|||||||
val codegenFactory = JvmIrCodegenFactory(configuration, phaseConfig)
|
val codegenFactory = JvmIrCodegenFactory(configuration, phaseConfig)
|
||||||
val generationState = GenerationState.Builder(
|
val generationState = GenerationState.Builder(
|
||||||
project, ClassBuilderFactories.TEST,
|
project, ClassBuilderFactories.TEST,
|
||||||
container.get(), NoScopeRecordCliBindingTrace().bindingContext, configuration
|
fir2irResult.irModuleFragment.descriptor, NoScopeRecordCliBindingTrace().bindingContext, configuration
|
||||||
).isIrBackend(
|
).isIrBackend(
|
||||||
true
|
true
|
||||||
).jvmBackendClassResolver(
|
).jvmBackendClassResolver(
|
||||||
|
|||||||
Reference in New Issue
Block a user