[K/JS] Add a secret system property to enable the old Kotlin/JS compiler only for tests until it will be removed from the sources

This commit is contained in:
Artem Kobzar
2022-12-29 13:32:01 +00:00
committed by Space Team
parent 47f32b715f
commit fbf06b5495
49 changed files with 109 additions and 16 deletions
@@ -55,7 +55,8 @@ enum class CompilerSystemProperties(val property: String, val alwaysDirectAccess
USER_HOME("user.home", alwaysDirectAccess = true),
JAVA_VERSION("java.specification.version", alwaysDirectAccess = true),
JAVA_HOME("java.home", alwaysDirectAccess = true),
JAVA_CLASS_PATH("java.class.path", alwaysDirectAccess = true)
JAVA_CLASS_PATH("java.class.path", alwaysDirectAccess = true),
KOTLIN_JS_COMPILER_LEGACY_FORCE_ENABLED("kotlin.js.compiler.legacy.force_enabled", alwaysDirectAccess = true)
;
private fun <T> getProperFunction(custom: T?, default: T): T {
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.cli.common.arguments
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.*
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
@@ -365,7 +366,7 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
collector.deprecationWarn(irBaseClassInMetadata, false, "-Xir-base-class-in-metadata")
collector.deprecationWarn(irNewIr2Js, true, "-Xir-new-ir2js")
if (languageVersion >= LanguageVersion.KOTLIN_1_9) {
if (languageVersion >= LanguageVersion.KOTLIN_1_9 && CompilerSystemProperties.KOTLIN_JS_COMPILER_LEGACY_FORCE_ENABLED.value != "true") {
collector.deprecationWarn(legacyDeprecatedNoWarn, false, "-Xlegacy-deprecated-no-warn")
collector.deprecationWarn(useDeprecatedLegacyCompiler, false, "-Xuse-deprecated-legacy-compiler")
}
@@ -184,7 +184,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
LanguageVersionSettings languageVersionSettings = CommonConfigurationKeysKt.getLanguageVersionSettings(configuration);
if (languageVersionSettings.getLanguageVersion().compareTo(LanguageVersion.KOTLIN_1_9) >= 0) {
if (CompilerSystemProperties.KOTLIN_JS_COMPILER_LEGACY_FORCE_ENABLED.getValue() != "true" && languageVersionSettings.getLanguageVersion().compareTo(LanguageVersion.KOTLIN_1_9) >= 0) {
messageCollector.report(ERROR, "Old Kotlin/JS compiler is no longer supported. Please migrate to the new JS IR backend", null);
return COMPILATION_ERROR;
}