JvmDefault. Add deprecation warning for '-Xjvm-default=enable|compatibility' options
#KT-46329
This commit is contained in:
committed by
Alexander Udalov
parent
42a465efe2
commit
8f60f73207
@@ -161,6 +161,10 @@ fun Project.configureKotlinCompilationOptions() {
|
|||||||
// TODO: fix remaining warnings and remove this property.
|
// TODO: fix remaining warnings and remove this property.
|
||||||
val tasksWithWarnings = listOf(
|
val tasksWithWarnings = listOf(
|
||||||
":kotlin-gradle-plugin:compileCommonKotlin",
|
":kotlin-gradle-plugin:compileCommonKotlin",
|
||||||
|
// Temporarily disable -Werror for the following modules because of deprecation warning for `-Xjvm-default=compatibility`.
|
||||||
|
// These modules should be removed after they are migrated to `-Xjvm-default=all/all-compatibility`.
|
||||||
|
":compiler:frontend:compileKotlin",
|
||||||
|
":kotlin-scripting-intellij:compileKotlin",
|
||||||
)
|
)
|
||||||
|
|
||||||
val projectsWithEnabledContextReceivers: List<String> by rootProject.extra
|
val projectsWithEnabledContextReceivers: List<String> by rootProject.extra
|
||||||
|
|||||||
@@ -70,9 +70,9 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val jvmDefaultMode = languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode)
|
||||||
val jvmTarget = get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
|
val jvmTarget = get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
|
||||||
if (jvmTarget.majorVersion < JvmTarget.JVM_1_8.majorVersion) {
|
if (jvmTarget.majorVersion < JvmTarget.JVM_1_8.majorVersion) {
|
||||||
val jvmDefaultMode = languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode)
|
|
||||||
if (jvmDefaultMode.forAllMethodsWithBody) {
|
if (jvmDefaultMode.forAllMethodsWithBody) {
|
||||||
messageCollector.report(
|
messageCollector.report(
|
||||||
ERROR,
|
ERROR,
|
||||||
@@ -81,6 +81,13 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (jvmDefaultMode == JvmDefaultMode.ENABLE || jvmDefaultMode == JvmDefaultMode.ENABLE_WITH_DEFAULT_IMPLS) {
|
||||||
|
messageCollector.report(
|
||||||
|
WARNING,
|
||||||
|
"'-Xjvm-default=${jvmDefaultMode.description}' is deprecated, please use '-Xjvm-default=all|all-compatibility'"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val stringConcat = arguments.stringConcat
|
val stringConcat = arguments.stringConcat
|
||||||
if (stringConcat != null) {
|
if (stringConcat != null) {
|
||||||
val runtimeStringConcat = JvmStringConcat.fromString(stringConcat)
|
val runtimeStringConcat = JvmStringConcat.fromString(stringConcat)
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/jvmDefaultAll.kt
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
|
-Xjvm-default=compatibility
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface Foo {
|
||||||
|
@JvmDefault
|
||||||
|
fun test() {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
warning: '-Xjvm-default=compatibility' is deprecated, please use '-Xjvm-default=all|all-compatibility'
|
||||||
|
OK
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/jvmDefaultAll.kt
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
|
-Xjvm-default=enable
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
interface Foo {
|
||||||
|
@JvmDefault
|
||||||
|
fun test() {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
warning: '-Xjvm-default=enable' is deprecated, please use '-Xjvm-default=all|all-compatibility'
|
||||||
|
OK
|
||||||
@@ -649,6 +649,16 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
runTest("compiler/testData/cli/jvm/jvmDefaultAll.args");
|
runTest("compiler/testData/cli/jvm/jvmDefaultAll.args");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmDefaultCompatibility.args")
|
||||||
|
public void testJvmDefaultCompatibility() throws Exception {
|
||||||
|
runTest("compiler/testData/cli/jvm/jvmDefaultCompatibility.args");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jvmDefaultEnable.args")
|
||||||
|
public void testJvmDefaultEnable() throws Exception {
|
||||||
|
runTest("compiler/testData/cli/jvm/jvmDefaultEnable.args");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("jvmIrByDefault1_4.args")
|
@TestMetadata("jvmIrByDefault1_4.args")
|
||||||
public void testJvmIrByDefault1_4() throws Exception {
|
public void testJvmIrByDefault1_4() throws Exception {
|
||||||
runTest("compiler/testData/cli/jvm/jvmIrByDefault1_4.args");
|
runTest("compiler/testData/cli/jvm/jvmIrByDefault1_4.args");
|
||||||
|
|||||||
Reference in New Issue
Block a user