From 419218b9cf20a28241adb2dc33b125e518451cd7 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Mon, 28 May 2018 16:14:58 +0200 Subject: [PATCH] Rename 'jvm-default-mode' to 'jvm-default'. Add description --- .../common/arguments/K2JVMCompilerArguments.kt | 15 ++++++++++----- .../jvm/diagnostics/DefaultErrorMessagesJvm.java | 6 +++--- compiler/testData/cli/jvm/extraHelp.out | 9 ++++++++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index 0d6d26cb459..80818324301 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -224,11 +224,16 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { var noExceptionOnExplicitEqualsForBoxedNull by FreezableVar(false) @Argument( - value = "-Xjvm-default-mode", + value = "-Xjvm-default", valueDescription = "{disable|enable|compatibility}", - description = "Allow to use '@JvmDefault' for JVM default method support" + description = "Allow to use '@JvmDefault' annotation for JVM default method support.\n" + + "-Xjvm-default=disable Prohibit usages of @JvmDefault\n" + + "-Xjvm-default=enable Allow usages of @JvmDefault; only generate the default method\n" + + " in the interface (annotating an existing method can break binary compatibility)\n" + + "-Xjvm-default=compatibility Allow usages of @JvmDefault; generate a compatibility accessor\n" + + " in the 'DefaultImpls' class in addition to the interface method\n" ) - var jvmDefaultMode: String by FreezableVar(JvmDefaultMode.DEFAULT.description) + var jvmDefault: String by FreezableVar(JvmDefaultMode.DEFAULT.description) @Argument(value = "-Xdisable-default-scripting-plugin", description = "Do not enable scripting plugin by default") var disableDefaultScriptingPlugin: Boolean by FreezableVar(false) @@ -246,10 +251,10 @@ class K2JVMCompilerArguments : CommonCompilerArguments() { supportCompatqualCheckerFrameworkAnnotations ) result[AnalysisFlag.ignoreDataFlowInAssert] = JVMAssertionsMode.fromString(assertionsMode) != JVMAssertionsMode.LEGACY - JvmDefaultMode.fromStringOrNull(jvmDefaultMode)?.let { result[AnalysisFlag.jvmDefaultMode] = it } + JvmDefaultMode.fromStringOrNull(jvmDefault)?.let { result[AnalysisFlag.jvmDefaultMode] = it } ?: collector.report( CompilerMessageSeverity.ERROR, - "Unknown @JvmDefault mode: $jvmDefaultMode, " + + "Unknown @JvmDefault mode: $jvmDefault, " + "supported modes: ${JvmDefaultMode.values().map { it.description }}" ) return result diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java index 45b926cfeb6..a3c5df9bd07 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java @@ -137,9 +137,9 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { MAP.put(JVM_DEFAULT_NOT_IN_INTERFACE,"'@JvmDefault' is only supported on interface members"); MAP.put(JVM_DEFAULT_IN_JVM6_TARGET,"'@JvmDefault' is only supported since JVM target 1.8. Recompile with '-jvm-target 1.8'"); MAP.put(JVM_DEFAULT_REQUIRED_FOR_OVERRIDE, "'@JvmDefault' is required for an override of a '@JvmDefault' member"); - MAP.put(JVM_DEFAULT_IN_DECLARATION, "Usage of '@JvmDefault' is only allowed with -Xjvm-default-mode option"); - MAP.put(JVM_DEFAULT_THROUGH_INHERITANCE, "Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default-mode option"); - MAP.put(USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL, "Super calls of '@JvmDefault' members are only allowed with -Xjvm-default-mode option"); + MAP.put(JVM_DEFAULT_IN_DECLARATION, "Usage of '@JvmDefault' is only allowed with -Xjvm-default option"); + MAP.put(JVM_DEFAULT_THROUGH_INHERITANCE, "Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option"); + MAP.put(USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL, "Super calls of '@JvmDefault' members are only allowed with -Xjvm-default option"); MAP.put(NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT, "Non-@JvmDefault interface method cannot override default Java method. Please annotate this method with @JvmDefault"); } diff --git a/compiler/testData/cli/jvm/extraHelp.out b/compiler/testData/cli/jvm/extraHelp.out index c5b86829893..94be734f148 100644 --- a/compiler/testData/cli/jvm/extraHelp.out +++ b/compiler/testData/cli/jvm/extraHelp.out @@ -18,7 +18,6 @@ where advanced options include: -Xdisable-default-scripting-plugin Do not enable scripting plugin by default -Xdisable-standard-script Disable standard kotlin script support - -Xenable-jvm-default Allow to use '@JvmDefault' for JVM default method support -Xmultifile-parts-inherit Compile multifile classes as a hierarchy of parts and facade -Xmodule-path= Paths where to find Java 9+ modules -Xjavac-arguments= Java compiler arguments @@ -31,6 +30,14 @@ where advanced options include: * ignore * strict (experimental; treat as other supported nullability annotations) * warn (report a warning) + -Xjvm-default={disable|enable|compatibility} + Allow to use '@JvmDefault' annotation for JVM default method support. + -Xjvm-default=disable Prohibit usages of @JvmDefault + -Xjvm-default=enable Allow usages of @JvmDefault; only generate the default method + in the interface (annotating an existing method can break binary compatibility) + -Xjvm-default=compatibility Allow usages of @JvmDefault; generate a compatibility accessor + in the 'DefaultImpls' class in addition to the interface method + -Xload-builtins-from-dependencies Load definitions of built-in declarations from module dependencies, instead of from the compiler -Xno-call-assertions Don't generate not-null assertions for arguments of platform types