Check target for -Xjvm-default modes
#KT-39925 Fixed
This commit is contained in:
@@ -38,6 +38,17 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
||||
}
|
||||
}
|
||||
|
||||
val jvmTarget = get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
|
||||
if (jvmTarget.bytecodeVersion < JvmTarget.JVM_1_8.bytecodeVersion) {
|
||||
val jvmDefaultMode = languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode)
|
||||
if (jvmDefaultMode.forAllMethodsWithBody) {
|
||||
messageCollector.report(
|
||||
ERROR,
|
||||
"'-Xjvm-default=${jvmDefaultMode.description}' is only supported since JVM target 1.8. Recompile with '-jvm-target 1.8'"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
addAll(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES, arguments.additionalJavaModules?.asList())
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
$TESTDATA_DIR$/jvmDefaultAll.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-jvm-target
|
||||
1.6
|
||||
-Xjvm-default=all
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
interface Foo {
|
||||
fun test() {}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
error: '-Xjvm-default=all' is only supported since JVM target 1.8. Recompile with '-jvm-target 1.8'
|
||||
COMPILATION_ERROR
|
||||
@@ -475,6 +475,11 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/jvm8Target.args");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmDefaultAll.args")
|
||||
public void testJvmDefaultAll() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/jvmDefaultAll.args");
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinHomeWithoutStdlib.args")
|
||||
public void testKotlinHomeWithoutStdlib() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/kotlinHomeWithoutStdlib.args");
|
||||
|
||||
Reference in New Issue
Block a user