Language version 2.0: fix compiler messages and minor details

This commit is contained in:
Mikhail Glukhikh
2023-01-09 11:51:48 +01:00
parent cbedbda527
commit 7a61578e08
12 changed files with 19 additions and 21 deletions
@@ -175,15 +175,15 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
ExitCode exitCode = OK;
LanguageVersionSettings languageVersionSettings = CommonConfigurationKeysKt.getLanguageVersionSettings(configuration);
LanguageVersion languageVersion = languageVersionSettings.getLanguageVersion();
if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments) || languageVersion.getUsesK2()) {
boolean useFir = Boolean.TRUE.equals(configuration.get(CommonConfigurationKeys.USE_FIR));
if (K2JSCompilerArgumentsKt.isIrBackendEnabled(arguments) || useFir) {
exitCode = getIrCompiler().doExecute(arguments, configuration.copy(), rootDisposable, paths);
}
if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments) || languageVersion.getUsesK2()) {
if (K2JSCompilerArgumentsKt.isPreIrBackendDisabled(arguments) || useFir) {
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);
@@ -104,19 +104,19 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
arguments.languageVersion == null -> {
messageCollector.report(
STRONG_WARNING,
"Compiler flag -Xuse-k2 is deprecated, please use -language-version 2.0 instead"
"Compiler flag -Xuse-k2 is deprecated, please use \"-language-version 2.0\" instead"
)
}
languageVersion.usesK2 -> {
messageCollector.report(
STRONG_WARNING,
"Compiler flag -Xuse-k2 is redundant"
"Compiler flag -Xuse-k2 is redundant, the \"-language-version 2.0\" is used instead"
)
}
else -> {
messageCollector.report(
STRONG_WARNING,
"With -Xuse-k2 compiler flag -language-version $languageVersion has no effect, please remove -Xuse-k2 flag or use -language-version 2.0 instead"
"With -Xuse-k2 compiler flag \"-language-version $languageVersion\" has no effect, please remove -Xuse-k2 flag and use \"-language-version 2.0\" instead"
)
}
}
@@ -202,7 +202,8 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
val pluginConfigurations = arguments.pluginConfigurations.orEmpty().toMutableList()
val messageCollector = configuration.getNotNull(MESSAGE_COLLECTOR_KEY)
if (!checkPluginsArguments(messageCollector, arguments.useK2, pluginClasspaths, pluginOptions, pluginConfigurations)) {
val useK2 = configuration.get(CommonConfigurationKeys.USE_FIR) == true
if (!checkPluginsArguments(messageCollector, useK2, pluginClasspaths, pluginOptions, pluginConfigurations)) {
return INTERNAL_ERROR
}
@@ -274,7 +275,7 @@ fun checkPluginsArguments(
hasErrors = true
messageCollector.report(
ERROR,
"-Xcompiler-plugin argument is allowed only for for K2 compiler. Please use -Xplugin argument or enable -Xuse-k2"
"-Xcompiler-plugin argument is allowed only for language version 2.0. Please use -Xplugin argument for language version 1.9 and below"
)
}
if (pluginClasspaths.isNotEmpty() || pluginOptions.isNotEmpty()) {
@@ -86,7 +86,7 @@ object FirKotlinToJvmBytecodeCompiler {
"""
|There are some plugins incompatible with language version 2.0:
|${notSupportedPlugins.joinToString(separator = "\n|") { " $it" }}
|Please use language version 1.* (e.g. 1.9)
|Please use language version 1.9 or below
""".trimMargin()
)
return false
@@ -59,7 +59,7 @@ class K2MetadataCompiler : CLICompiler<K2MetadataCompilerArguments>() {
): ExitCode {
val collector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
if (configuration.getBoolean(CommonConfigurationKeys.USE_FIR)) {
collector.report(ERROR, "Compilation to metadata is not supported in language version 2.0 right now")
collector.report(ERROR, "Compilation to metadata is not supported with language version 2.0 right now")
return ExitCode.COMPILATION_ERROR
}
val performanceManager = configuration.getNotNull(CLIConfigurationKeys.PERF_MANAGER)
+1 -1
View File
@@ -1,3 +1,3 @@
warning: compiler flag -Xuse-k2 is deprecated, please use -language-version 2.0 instead
warning: compiler flag -Xuse-k2 is deprecated, please use "-language-version 2.0" instead
warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features
OK
+1 -1
View File
@@ -1,3 +1,3 @@
warning: compiler flag -Xuse-k2 is redundant
warning: compiler flag -Xuse-k2 is redundant, the "-language-version 2.0" is used instead
warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features
OK
+1 -1
View File
@@ -1,3 +1,3 @@
warning: with -Xuse-k2 compiler flag -language-version 1.5 has no effect, please remove -Xuse-k2 flag or use -language-version 2.0 instead
warning: with -Xuse-k2 compiler flag "-language-version 1.5" has no effect, please remove -Xuse-k2 flag and use "-language-version 2.0" instead
warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features
OK
+1 -1
View File
@@ -1,3 +1,3 @@
warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features
error: compilation to metadata is not supported in language version 2.0 right now
error: compilation to metadata is not supported with language version 2.0 right now
COMPILATION_ERROR
@@ -1,2 +1,2 @@
warning: compiler flag -Xuse-k2 is deprecated, please use -language-version 2.0 instead
warning: compiler flag -Xuse-k2 is deprecated, please use "-language-version 2.0" instead
OK
@@ -58,9 +58,6 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
if (pluginLoadResult != ExitCode.OK) return pluginLoadResult
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) ?: MessageCollector.NONE
if (configuration.getBoolean(CommonConfigurationKeys.USE_FIR)) {
messageCollector.report(WARNING, "New compiler pipeline K2 is experimental in Kotlin/Native. No compatibility guarantees are yet provided")
}
val enoughArguments = arguments.freeArgs.isNotEmpty() || arguments.isUsefulWithoutFreeArgs
if (!enoughArguments) {
@@ -146,7 +146,7 @@ private val apiVersionValues = ApiVersion.run {
KOTLIN_1_7,
KOTLIN_1_8,
KOTLIN_1_9,
KOTLIN_2_0
KOTLIN_2_0,
)
}
@@ -71,7 +71,7 @@ class Kapt3CommandLineProcessor : CommandLineProcessor {
if (configuration.getBoolean(CommonConfigurationKeys.USE_FIR)) {
configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]?.report(
CompilerMessageSeverity.ERROR,
"kapt currently doesn't support language version 2.0\nPlease use language version 1.* (e.g. 1.9) instead"
"kapt currently doesn't support language version 2.0\nPlease use language version 1.9 or below"
)
}