From 982617272081bef112c1ec11d2f7af09852edddb Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 1 Feb 2022 21:43:29 +0100 Subject: [PATCH] CLI: support "arg=value" for argument's deprecatedName #KT-51093 Fixed --- .../arguments/parseCommandLineArguments.kt | 23 ++++++------------- .../cli/jvm/experimentalDeprecatedWarning.out | 2 +- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/parseCommandLineArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/parseCommandLineArguments.kt index a90bbb3eccb..fc0aa6136c9 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/parseCommandLineArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/parseCommandLineArguments.kt @@ -87,29 +87,20 @@ private fun parsePreprocessedCommandLineArguments(args return true } - val deprecatedName = argument.deprecatedName.takeUnless(String::isEmpty) - if (deprecatedName == arg) { + val deprecatedName = argument.deprecatedName + if (deprecatedName.isNotEmpty() && (deprecatedName == arg || arg.startsWith("$deprecatedName="))) { errors.deprecatedArguments[deprecatedName] = argument.value return true } - if (argument.isAdvanced) { - if (argument.value == arg) { - if (property.returnType.classifier != Boolean::class) { - errors.extraArgumentsPassedInObsoleteForm.add(arg) - } - return true + if (argument.value == arg) { + if (argument.isAdvanced && property.returnType.classifier != Boolean::class) { + errors.extraArgumentsPassedInObsoleteForm.add(arg) } - - if (deprecatedName != null && arg.startsWith("$deprecatedName=")) { - errors.deprecatedArguments[deprecatedName] = argument.value - return true - } - - return arg.startsWith(argument.value + "=") + return true } - return argument.value == arg || arg.startsWith(argument.value + "=") + return arg.startsWith(argument.value + "=") } val freeArgs = ArrayList() diff --git a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out index 8d939d49e07..03e36c75643 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out +++ b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out @@ -1,3 +1,3 @@ -warning: flag is not supported by this version of the compiler: -Xopt-in=kotlin.RequiresOptIn +warning: argument -Xopt-in is deprecated. Please use -opt-in instead warning: opt-in requirement marker org.test.Warning is deprecated. Warning OK