From 73a0b4eaf2ab09eeb31263a1899240fc7d6fc6f5 Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Wed, 29 Nov 2023 16:38:58 +0100 Subject: [PATCH] [JVM_IR] Don't use `irPluginContext` at all when compiling code fragment This is an extended version of the fix in 57d912a5d4ddc66e7827f9e0d15910351b155c41. We don't want to use any plugins in code fragment compilation, but we still get them through `project` because they are registered in IDEA. So we just fully exclude `irPluginContext`. #KT-63695 Fixed --- .../org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt | 6 +++--- .../org/jetbrains/kotlin/test/backend/ir/IrBackendInput.kt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt b/compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt index 6992ea7fe5a..c02d5c9845b 100644 --- a/compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt +++ b/compiler/ir/backend.jvm/entrypoint/src/org/jetbrains/kotlin/backend/jvm/JvmIrCodegenFactory.kt @@ -116,7 +116,7 @@ open class JvmIrCodegenFactory( val irProviders: List, val extensions: JvmGeneratorExtensions, val backendExtension: JvmBackendExtension, - val pluginContext: IrPluginContext, + val pluginContext: IrPluginContext?, val notifyCodegenStart: () -> Unit ) : CodegenFactory.BackendInput @@ -212,8 +212,8 @@ open class JvmIrCodegenFactory( psi2irContext.irBuiltIns, irLinker, messageLogger - ) - if (pluginExtensions.isNotEmpty() && !ideCodegenSettings.shouldStubAndNotLinkUnboundSymbols) { + ).takeIf { !ideCodegenSettings.shouldStubAndNotLinkUnboundSymbols } + if (pluginExtensions.isNotEmpty() && pluginContext != null) { for (extension in pluginExtensions) { if (psi2irContext.configuration.generateBodies || @OptIn(FirIncompatiblePluginAPI::class) extension.shouldAlsoBeAppliedInKaptStubGenerationMode diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/IrBackendInput.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/IrBackendInput.kt index 8b8f1985acd..0ca974a6999 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/IrBackendInput.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/backend/ir/IrBackendInput.kt @@ -115,7 +115,7 @@ sealed class IrBackendInput : ResultingArtifact.BackendInput() { get() = backendInput.irModuleFragment override val irPluginContext: IrPluginContext - get() = backendInput.pluginContext + get() = backendInput.pluginContext!! override val diagnosticReporter: BaseDiagnosticsCollector get() = state.diagnosticReporter as BaseDiagnosticsCollector