From 7e0f69b8decaf419d5e6210022d153d6800690de Mon Sep 17 00:00:00 2001 From: Stanislav Ruban Date: Thu, 26 Jan 2023 11:55:03 +0000 Subject: [PATCH] Introduce tweaks and wording changes related to LV2.0-specific CLI warnings Fix merge conflict related to renaming of one of the tests Regenerate tests affected by previous commit Fix merge conflict related to renaming of one of the tests Improve wording of the `-Xuse-k2 -language-version 1.*` CLI warning Improve wording of LV2.0-specific CLI warnings some more Fix output of one of the tests for -Xuse-k2 deprecation Tweak wording of LV2.0-specific CLI warnings * make it clear in every warning that -Xuse-k2 is deprecated * add a reminder to remove -Xuse-k2 for `-Xuse-k2 -language-version 2.0` * add both possibly wanted fixes for `-Xuse-k2 -language-version 1.*` Remove deprecated -Xuse-k2 flag from one of the tests Merge-request: KT-MR-8449 Merged-by: Stanislav Ruban --- .../arguments/CommonCompilerArguments.kt | 29 ++++++------------- compiler/testData/cli/jvm/firHello.out | 2 +- .../testData/cli/jvm/firHello20WithFlag.out | 2 +- .../testData/cli/jvm/firHello20WithOldLV.out | 2 +- .../firAgainstFirUsingFlag/output.txt | 2 +- 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index 0bdd5b39efa..d1092d2c097 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -711,27 +711,16 @@ abstract class CommonCompilerArguments : CommonToolArguments() { val explicitVersion = parseVersion(collector, languageVersion, "language") val explicitOrDefaultVersion = explicitVersion ?: defaultLanguageVersion(collector) if (useK2) { - when { - explicitVersion?.usesK2 == true -> { - collector.report( - CompilerMessageSeverity.STRONG_WARNING, - "Compiler flag -Xuse-k2 is redundant, the \"-language-version 2.0\" is used instead" - ) - } - explicitVersion != null -> { - collector.report( - CompilerMessageSeverity.STRONG_WARNING, - "With -Xuse-k2 compiler flag \"-language-version $explicitVersion\" has no effect," + - " please remove -Xuse-k2 flag and use \"-language-version 2.0\" instead" - ) - } - else -> { - collector.report( - CompilerMessageSeverity.STRONG_WARNING, - "Compiler flag -Xuse-k2 is deprecated, please use \"-language-version 2.0\" instead" - ) - } + val message = when (explicitVersion?.usesK2) { + true -> + "Deprecated compiler flag -Xuse-k2 is redundant because of \"-language-version $explicitVersion\" and should be removed" + false -> + "Deprecated compiler flag -Xuse-k2 overrides \"-language-version $explicitVersion\" to 2.0;" + + " please remove -Xuse-k2 and use -language-version to select either $explicitVersion or 2.0" + null -> + "Compiler flag -Xuse-k2 is deprecated; please use \"-language-version 2.0\" instead" } + collector.report(CompilerMessageSeverity.STRONG_WARNING, message) } return if (useK2 && !explicitOrDefaultVersion.usesK2) LanguageVersion.KOTLIN_2_0 else explicitOrDefaultVersion diff --git a/compiler/testData/cli/jvm/firHello.out b/compiler/testData/cli/jvm/firHello.out index cc6ea4c496a..52c758d7734 100644 --- a/compiler/testData/cli/jvm/firHello.out +++ b/compiler/testData/cli/jvm/firHello.out @@ -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 diff --git a/compiler/testData/cli/jvm/firHello20WithFlag.out b/compiler/testData/cli/jvm/firHello20WithFlag.out index b9be8766ccf..b233bd36d45 100644 --- a/compiler/testData/cli/jvm/firHello20WithFlag.out +++ b/compiler/testData/cli/jvm/firHello20WithFlag.out @@ -1,3 +1,3 @@ -warning: compiler flag -Xuse-k2 is redundant, the "-language-version 2.0" is used instead +warning: deprecated compiler flag -Xuse-k2 is redundant because of "-language-version 2.0" and should be removed warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features OK diff --git a/compiler/testData/cli/jvm/firHello20WithOldLV.out b/compiler/testData/cli/jvm/firHello20WithOldLV.out index c58f921bef1..321bc7468f3 100644 --- a/compiler/testData/cli/jvm/firHello20WithOldLV.out +++ b/compiler/testData/cli/jvm/firHello20WithOldLV.out @@ -1,3 +1,3 @@ -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: deprecated compiler flag -Xuse-k2 overrides "-language-version 1.5" to 2.0; please remove -Xuse-k2 and use -language-version to select either 1.5 or 2.0 warning: language version 2.0 is experimental, there are no backwards compatibility guarantees for new language and library features OK diff --git a/compiler/testData/compileKotlinAgainstCustomBinaries/firAgainstFirUsingFlag/output.txt b/compiler/testData/compileKotlinAgainstCustomBinaries/firAgainstFirUsingFlag/output.txt index 01275a94aad..01587e29e8e 100644 --- a/compiler/testData/compileKotlinAgainstCustomBinaries/firAgainstFirUsingFlag/output.txt +++ b/compiler/testData/compileKotlinAgainstCustomBinaries/firAgainstFirUsingFlag/output.txt @@ -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