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