Always use default 1.6 build target unless of 'jvm-target' option

This commit is contained in:
Mikhael Bogdanov
2016-12-12 10:33:33 +01:00
parent ef662a5679
commit dc5c3a478c
14 changed files with 27 additions and 106 deletions
@@ -111,9 +111,6 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
@Argument(value = "Xload-builtins-from-dependencies", description = "Load definitions of built-in declarations from module dependencies, instead of from the compiler")
public boolean loadBuiltInsFromDependencies;
@Argument(value = "Xinterface-compatibility", description = "Generate DefaultImpls classes for interfaces in JVM target bytecode version 1.8 for binary compatibility with 1.6")
public boolean interfaceCompatibility;
// Paths to output directories for friend modules.
public String[] friendPaths;
@@ -133,7 +133,12 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
if (arguments.jvmTarget != null) {
val jvmTarget = JvmTarget.fromString(arguments.jvmTarget)
if (jvmTarget != null) {
configuration.put(JVMConfigurationKeys.JVM_TARGET, jvmTarget)
if (jvmTarget == JvmTarget.JVM_1_8) {
val warning = "The -jvm-target option has no effect yet"
messageCollector.report(CompilerMessageSeverity.WARNING, warning, CompilerMessageLocation.NO_LOCATION)
}
//use default target for now
//configuration.put(JVMConfigurationKeys.JVM_TARGET, jvmTarget)
}
else {
val errorMessage = "Unknown JVM target version: ${arguments.jvmTarget}\n" +
@@ -144,17 +149,6 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
configuration.put(JVMConfigurationKeys.PARAMETERS_METADATA, arguments.javaParameters)
if (arguments.interfaceCompatibility) {
val target = configuration.get(JVMConfigurationKeys.JVM_TARGET)
if (target != JvmTarget.JVM_1_8) {
val errorMessage = "The -Xinterface-compatibility option has effect only for JVM target bytecode version 1.8."
messageCollector.report(CompilerMessageSeverity.WARNING, errorMessage, CompilerMessageLocation.NO_LOCATION)
}
else {
configuration.put(JVMConfigurationKeys.INTERFACE_COMPATIBILITY, true)
}
}
putAdvancedOptions(configuration, arguments)
messageCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment", CompilerMessageLocation.NO_LOCATION)
-1
View File
@@ -12,7 +12,6 @@ where advanced options include:
-Xadd-compiler-builtins Add definitions of built-in declarations to the compilation classpath (useful with -no-stdlib)
-Xload-builtins-from-dependencies
Load definitions of built-in declarations from module dependencies, instead of from the compiler
-Xinterface-compatibility Generate DefaultImpls classes for interfaces in JVM target bytecode version 1.8 for binary compatibility with 1.6
-Xno-inline Disable method inlining
-Xrepeat <count> Repeat compilation (for performance analysis)
-Xplugin <path> Load plugins from the given classpath
+6
View File
@@ -0,0 +1,6 @@
$TESTDATA_DIR$/jvm8Target.kt
-d
$TEMP_DIR$
-jvm-target
1.8
+7
View File
@@ -0,0 +1,7 @@
interface A {
fun test() = "OK"
}
fun main(args: Array<String>) {
println(object : A {}.test())
}
+2
View File
@@ -0,0 +1,2 @@
warning: the -jvm-target option has no effect yet
OK
@@ -1,13 +0,0 @@
interface Z2 : Z {
}
class Z2Class : Z {
override fun test() {
}
}
fun main(args: Array<String>) {
}
@@ -1,10 +0,0 @@
compiler/testData/compileKotlinAgainstCustomBinaries/target6Inheritance/main.kt:1:1: error: compiling 'Z2' to JVM 1.8, but its superinterface 'Z' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z':
val z: String
fun test(): Unit
interface Z2 : Z {
^
compiler/testData/compileKotlinAgainstCustomBinaries/target6Inheritance/main.kt:5:1: error: compiling 'Z2Class' to JVM 1.8, but its superinterface 'Z' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z':
val z: String
class Z2Class : Z {
^
COMPILATION_ERROR
@@ -1,9 +0,0 @@
interface Z {
fun test() {
}
val z: String
get() = "OK"
}
@@ -1,14 +0,0 @@
interface Z3 : Z, Z2 {
}
class Z3Class : Z, Z2 {
override fun test() {
}
}
fun main(args: Array<String>) {
}
@@ -1,13 +0,0 @@
compiler/testData/compileKotlinAgainstCustomBinaries/target6MultiInheritance/main.kt:1:1: error: compiling 'Z3' to JVM 1.8, but its superinterface 'Z' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z':
fun test(): Unit
interface Z3 : Z, Z2 {
^
compiler/testData/compileKotlinAgainstCustomBinaries/target6MultiInheritance/main.kt:1:1: error: compiling 'Z3' to JVM 1.8, but its superinterface 'Z2' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z2':
val z: String
interface Z3 : Z, Z2 {
^
compiler/testData/compileKotlinAgainstCustomBinaries/target6MultiInheritance/main.kt:5:1: error: compiling 'Z3Class' to JVM 1.8, but its superinterface 'Z2' was compiled for JVM 1.6. Method implementation inheritance is restricted for such cases. Please make explicit overrides (abstract or concrete) for the following non-abstract members of 'Z2':
val z: String
class Z3Class : Z, Z2 {
^
COMPILATION_ERROR
@@ -1,13 +0,0 @@
interface Z {
fun test() {
}
}
interface Z2 {
val z: String
get() = "OK"
}
@@ -176,6 +176,12 @@ public class CliTestGenerated extends AbstractCliTest {
doJvmTest(fileName);
}
@TestMetadata("jvm8Target.args")
public void testJvm8Target() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jvm8Target.args");
doJvmTest(fileName);
}
@TestMetadata("kotlinPackage.args")
public void testKotlinPackage() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/kotlinPackage.args");
@@ -546,24 +546,6 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
);
}
public void testTarget6Inheritance() throws Exception {
target6Inheritance();
}
public void testTarget6MultiInheritance() throws Exception {
target6Inheritance();
}
private void target6Inheritance() {
compileKotlin("target6.kt", tmpdir);
Pair<String, ExitCode> outputMain = compileKotlin("main.kt", tmpdir, Arrays.asList("-jvm-target", "1.8"), tmpdir);
KotlinTestUtils.assertEqualsToFile(
new File(getTestDataDirectory(), "output.txt"), normalizeOutput(outputMain)
);
}
public void testTypeAliasesAreInvisibleInCompatibilityMode() {
compileKotlin("typeAliases.kt", tmpdir);