Create plugin context before launching actual psi2ir process.
Because IrPluginContextImpl constructor creates new instance of BuiltinSymbolsBase (with symbols for stdlib declarations like `arrayOf` etc), there should be at least one pass of `declareUnboundSymbolsAsDependencies` between creation and usage in plugin. Such pass is located between psi2ir and compiler plugins application. If plugin context is created inside lambda, right before plugins are applied, the symbols will remain unbound. #KT-41764 Fixed
This commit is contained in:
@@ -314,20 +314,22 @@ fun GeneratorContext.generateModuleFragmentWithPlugins(
|
|||||||
|
|
||||||
val extensions = IrGenerationExtension.getInstances(project)
|
val extensions = IrGenerationExtension.getInstances(project)
|
||||||
|
|
||||||
for (extension in extensions) {
|
if (extensions.isNotEmpty()) {
|
||||||
psi2Ir.addPostprocessingStep { module ->
|
// plugin context should be instantiated before postprocessing steps
|
||||||
extension.generate(
|
val pluginContext = IrPluginContextImpl(
|
||||||
module,
|
moduleDescriptor,
|
||||||
IrPluginContextImpl(
|
bindingContext,
|
||||||
moduleDescriptor,
|
languageVersionSettings,
|
||||||
bindingContext,
|
symbolTable,
|
||||||
languageVersionSettings,
|
typeTranslator,
|
||||||
symbolTable,
|
irBuiltIns,
|
||||||
typeTranslator,
|
linker = irLinker
|
||||||
irBuiltIns,
|
)
|
||||||
linker = irLinker
|
|
||||||
)
|
for (extension in extensions) {
|
||||||
)
|
psi2Ir.addPostprocessingStep { module ->
|
||||||
|
extension.generate(module, pluginContext)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user