From 4a00d1f978262dec94b26ea84c79dd986d38a36a Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 23 Sep 2022 20:36:37 +0200 Subject: [PATCH] Add internal way to enable old backend Needed for tests on debugger in Kotlin IDE plugin. --- .../cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 764b687fdcc..3a217ac65f0 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -123,8 +123,9 @@ class K2JVMCompiler : CLICompiler() { } if (arguments.useOldBackend) { - messageCollector.report(ERROR, "-Xuse-old-backend is no longer supported. Please migrate to the new JVM IR backend") - return COMPILATION_ERROR + val severity = if (isUseOldBackendAllowed()) WARNING else ERROR + messageCollector.report(severity, "-Xuse-old-backend is no longer supported. Please migrate to the new JVM IR backend") + if (severity == ERROR) return COMPILATION_ERROR } messageCollector.report(LOGGING, "Configuring the compilation environment") @@ -260,6 +261,9 @@ class K2JVMCompiler : CLICompiler() { val argument = arguments.profileCompilerCommand ?: return defaultPerformanceManager return ProfilingCompilerPerformanceManager.create(argument) } + + private fun isUseOldBackendAllowed(): Boolean = + K2JVMCompiler::class.java.classLoader.getResource("META-INF/unsafe-allow-use-old-backend") != null } fun CompilerConfiguration.configureModuleChunk(