From 195b6d1fb1d5b72b13a0997d2b607b9c101d9287 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 7 Jul 2021 12:03:03 +0300 Subject: [PATCH] Deprecate -Xuse-experimental #KT-47623 Fixed --- .../cli/common/arguments/CommonCompilerArguments.kt | 9 +++++++-- .../testData/cli/jvm/experimentalDeprecatedWarning.args | 1 + .../testData/cli/jvm/experimentalDeprecatedWarning.kt | 3 +++ .../testData/cli/jvm/experimentalDeprecatedWarning.out | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index 96d8525148f..ed49a397c04 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.cli.common.arguments import com.intellij.util.xmlb.annotations.Transient import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.WARNING import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.config.* import java.util.* @@ -379,9 +380,13 @@ abstract class CommonCompilerArguments : CommonToolArguments() { val experimentalFqNames = experimental?.toList().orEmpty() if (experimentalFqNames.isNotEmpty()) { put(AnalysisFlags.experimental, experimentalFqNames) - collector.report(CompilerMessageSeverity.WARNING, "'-Xexperimental' is deprecated and will be removed in a future release") + collector.report(WARNING, "'-Xexperimental' is deprecated and will be removed in a future release") } - put(AnalysisFlags.useExperimental, useExperimental?.toList().orEmpty() + optIn?.toList().orEmpty()) + val useExperimentalFqNames = useExperimental?.toList().orEmpty() + if (useExperimentalFqNames.isNotEmpty()) { + collector.report(WARNING, "'-Xuse-experimental' is deprecated and will be removed in a future release") + } + put(AnalysisFlags.useExperimental, useExperimentalFqNames + optIn?.toList().orEmpty()) put(AnalysisFlags.expectActualLinker, expectActualLinker) put(AnalysisFlags.explicitApiVersion, apiVersion != null) put(AnalysisFlags.allowResultReturnType, allowResultReturnType) diff --git a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.args b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.args index a20c699fb90..52cd157f3c9 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.args +++ b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.args @@ -4,3 +4,4 @@ $TEMP_DIR$ -Xopt-in=kotlin.RequiresOptIn -Xopt-in=org.test.Warning1 -Xexperimental=org.test.Warning2 +-Xuse-experimental=org.test.OneMore diff --git a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt index da1bc5e10d8..d19ead74f08 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt +++ b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt @@ -9,3 +9,6 @@ annotation class Warning1 @RequiresOptIn @Retention(AnnotationRetention.BINARY) annotation class Warning2 + +@RequiresOptIn +annotation class OneMore diff --git a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out index e179ed007bc..4b200d596cb 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out +++ b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out @@ -1,4 +1,5 @@ warning: '-Xexperimental' is deprecated and will be removed in a future release +warning: '-Xuse-experimental' is deprecated and will be removed in a future release warning: opt-in requirement marker org.test.Warning2 is deprecated. Warning2 warning: opt-in requirement marker org.test.Warning1 is deprecated. Warning1 OK