Enable JVM IR by default if language version is >= 1.5

#KT-44021 Fixed
This commit is contained in:
Alexander Udalov
2020-12-30 21:57:45 +01:00
parent 22d0e5eb65
commit cb3191769d
10 changed files with 45 additions and 1 deletions
@@ -165,7 +165,12 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
put(JVMConfigurationKeys.PARAMETERS_METADATA, arguments.javaParameters)
val useIR = (arguments.useIR && !arguments.useOldBackend) || arguments.useFir
val useIR = arguments.useFir ||
if (languageVersionSettings.supportsFeature(LanguageFeature.JvmIrEnabledByDefault)) {
!arguments.useOldBackend
} else {
arguments.useIR && !arguments.useOldBackend
}
put(JVMConfigurationKeys.IR, useIR)
val abiStability = JvmAbiStability.fromStringOrNull(arguments.abiStability)
+13
View File
@@ -0,0 +1,13 @@
// This test checks that with -language-version 1.4 we're using the old JVM backend,
// and with -language-version 1.5 -- the new JVM IR backend.
// JVM IR doesn't produce classes for local functions, so the test checks which backend
// is used by asserting that the file for the anonymous class does or doesn't exist.
// Feel free to remove both _1_4 and _1_5 tests as soon as either the old JVM backend
// or LV 1.4 is removed, whichever happens earlier.
class C {
fun test() {
fun local() {}
}
}
+5
View File
@@ -0,0 +1,5 @@
$TESTDATA_DIR$/jvmIrByDefault.kt
-d
$TEMP_DIR$
-language-version
1.4
+1
View File
@@ -0,0 +1 @@
OK
+1
View File
@@ -0,0 +1 @@
// EXISTS: C$test$1.class
+5
View File
@@ -0,0 +1,5 @@
$TESTDATA_DIR$/jvmIrByDefault.kt
-d
$TEMP_DIR$
-language-version
1.5
+2
View File
@@ -0,0 +1,2 @@
warning: language version 1.5 is experimental, there are no backwards compatibility guarantees for new language and library features
OK
+1
View File
@@ -0,0 +1 @@
// ABSENT: C$test$1.class
@@ -541,6 +541,16 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/jvmDefaultAll.args");
}
@TestMetadata("jvmIrByDefault1_4.args")
public void testJvmIrByDefault1_4() throws Exception {
runTest("compiler/testData/cli/jvm/jvmIrByDefault1_4.args");
}
@TestMetadata("jvmIrByDefault1_5.args")
public void testJvmIrByDefault1_5() throws Exception {
runTest("compiler/testData/cli/jvm/jvmIrByDefault1_5.args");
}
@TestMetadata("jvmRecordOk.args")
public void testJvmRecordOk() throws Exception {
runTest("compiler/testData/cli/jvm/jvmRecordOk.args");
@@ -144,6 +144,7 @@ enum class LanguageFeature(
AllowSealedInheritorsInDifferentFilesOfSamePackage(KOTLIN_1_5),
SealedInterfaces(KOTLIN_1_5),
JvmIrEnabledByDefault(KOTLIN_1_5),
/*
* Improvements include the following: