CLI: improve error message for -Xjdk-release=1.6/1.7

#KT-66174 Fixed
This commit is contained in:
Alexander Udalov
2024-02-27 18:53:04 +01:00
committed by Space Team
parent 5f261d3ad0
commit 939a74add3
5 changed files with 22 additions and 4 deletions
@@ -43,10 +43,12 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
put(JVMConfigurationKeys.JDK_RELEASE, value)
}
if (jvmTargetArg != null && !isCompatibleJvmTargetAndRelease(jvmTargetArg, releaseTargetArg)) {
val suggestion =
if (value < 8) "Please change the value of the 'jvm-target' option to 1.8"
else "Please remove the '-jvm-target' option"
messageCollector.report(
ERROR,
"'-Xjdk-release=$releaseTargetArg' option conflicts with '-jvm-target $jvmTargetArg'. " +
"Please remove the '-jvm-target' option"
"'-Xjdk-release=$releaseTargetArg' option conflicts with '-jvm-target $jvmTargetArg'. $suggestion"
)
}
}
@@ -57,7 +59,8 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
if (jvmTargetArg == null) {
messageCollector.report(
ERROR,
"'-Xjdk-release=$releaseTargetArg' option requires explicit JVM target. Please specify the '-jvm-target' option"
"'-Xjdk-release=$releaseTargetArg' option requires JVM target explicitly set to 1.8. " +
"Please specify the '-jvm-target' option"
)
}
jvmTargetArg
@@ -0,0 +1,8 @@
-Xjdk-release=1.6
-jvm-target
9
-jdk-home
$JDK_11_0
$TESTDATA_DIR$/jdkRelease.kt
-d
$TEMP_DIR$
@@ -0,0 +1,2 @@
error: '-Xjdk-release=1.6' option conflicts with '-jvm-target 9'. Please change the value of the 'jvm-target' option to 1.8
COMPILATION_ERROR
@@ -1,2 +1,2 @@
error: '-Xjdk-release=1.6' option requires explicit JVM target. Please specify the '-jvm-target' option
error: '-Xjdk-release=1.6' option requires JVM target explicitly set to 1.8. Please specify the '-jvm-target' option
COMPILATION_ERROR
@@ -775,6 +775,11 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/jdkRelease6WithJvmTarget8Jdk8.args");
}
@TestMetadata("jdkRelease6WithJvmTarget9.args")
public void testJdkRelease6WithJvmTarget9() {
runTest("compiler/testData/cli/jvm/jdkRelease6WithJvmTarget9.args");
}
@TestMetadata("jdkRelease6WithoutExplicitJvmTarget.args")
public void testJdkRelease6WithoutExplicitJvmTarget() {
runTest("compiler/testData/cli/jvm/jdkRelease6WithoutExplicitJvmTarget.args");