Introduce language version 2.0 and associate K2 compiler with it

This commit is contained in:
Mikhail Glukhikh
2022-11-28 18:20:10 +01:00
parent afe1150aec
commit 3dc05f4ec5
84 changed files with 233 additions and 151 deletions
@@ -175,14 +175,15 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
ExitCode exitCode = OK;
if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments)) {
LanguageVersionSettings languageVersionSettings = CommonConfigurationKeysKt.getLanguageVersionSettings(configuration);
LanguageVersion languageVersion = languageVersionSettings.getLanguageVersion();
if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments) || languageVersion.getUsesK2()) {
exitCode = getIrCompiler().doExecute(arguments, configuration.copy(), rootDisposable, paths);
}
if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments)) {
if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments) || languageVersion.getUsesK2()) {
return exitCode;
}
LanguageVersionSettings languageVersionSettings = CommonConfigurationKeysKt.getLanguageVersionSettings(configuration);
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);
@@ -287,11 +287,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
val outputKlibPath =
if (arguments.irProduceKlibFile) outputDir.resolve("$outputName.klib").normalize().absolutePath
else outputDirPath
if (arguments.useK2) {
messageCollector.report(
STRONG_WARNING,
"ATTENTION!\n This build uses experimental K2 compiler: \n -Xuse-k2"
)
if (configuration.get(CommonConfigurationKeys.USE_FIR) == true) {
sourceModule = processSourceModuleWithK2(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)
} else {
sourceModule = processSourceModule(environmentForJS, libraries, friendLibraries, arguments, outputKlibPath)