Introduce -opt-in stable compiler option instead of -Xopt-in

#KT-47099 Fixed
This commit is contained in:
Mikhail Glukhikh
2021-07-07 12:51:36 +03:00
committed by teamcityserver
parent 47c8bab48e
commit d8417fd622
16 changed files with 56 additions and 20 deletions
@@ -83,6 +83,15 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
@Argument(value = "-P", valueDescription = PLUGIN_OPTION_FORMAT, description = "Pass an option to a plugin") @Argument(value = "-P", valueDescription = PLUGIN_OPTION_FORMAT, description = "Pass an option to a plugin")
var pluginOptions: Array<String>? by FreezableVar(null) var pluginOptions: Array<String>? by FreezableVar(null)
@Argument(
value = "-opt-in",
// Uncomment after deletion of optInDeprecated
// deprecatedName = "-Xopt-in",
valueDescription = "<fq.name>",
description = "Enable usages of API that requires opt-in with an opt-in requirement marker with the given fully qualified name"
)
var optIn: Array<String>? by FreezableVar(null)
// Advanced options // Advanced options
@Argument(value = "-Xno-inline", description = "Disable method inlining") @Argument(value = "-Xno-inline", description = "Disable method inlining")
@@ -172,12 +181,13 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
) )
var useExperimental: Array<String>? by FreezableVar(null) var useExperimental: Array<String>? by FreezableVar(null)
// NB: we have to keep this flag for some time due to bootstrapping problems
@Argument( @Argument(
value = "-Xopt-in", value = "-Xopt-in",
valueDescription = "<fq.name>", valueDescription = "<fq.name>",
description = "Enable usages of API that requires opt-in with an opt-in requirement marker with the given fully qualified name" description = "Enable usages of API that requires opt-in with an opt-in requirement marker with the given fully qualified name"
) )
var optIn: Array<String>? by FreezableVar(null) var optInDeprecated: Array<String>? by FreezableVar(null)
@Argument( @Argument(
value = "-Xproper-ieee754-comparisons", value = "-Xproper-ieee754-comparisons",
@@ -384,9 +394,17 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
} }
val useExperimentalFqNames = useExperimental?.toList().orEmpty() val useExperimentalFqNames = useExperimental?.toList().orEmpty()
if (useExperimentalFqNames.isNotEmpty()) { if (useExperimentalFqNames.isNotEmpty()) {
collector.report(WARNING, "'-Xuse-experimental' is deprecated and will be removed in a future release") collector.report(
WARNING, "'-Xuse-experimental' is deprecated and will be removed in a future release, please use -opt-in instead"
)
} }
put(AnalysisFlags.useExperimental, useExperimentalFqNames + optIn?.toList().orEmpty()) val optInDeprecatedFqNames = optInDeprecated?.toList().orEmpty()
if (optInDeprecatedFqNames.isNotEmpty()) {
collector.report(
WARNING, "'-Xopt-in' is deprecated and will be removed in a future release, please use -opt-in instead"
)
}
put(AnalysisFlags.useExperimental, useExperimentalFqNames + optInDeprecatedFqNames + optIn?.toList().orEmpty())
put(AnalysisFlags.expectActualLinker, expectActualLinker) put(AnalysisFlags.expectActualLinker, expectActualLinker)
put(AnalysisFlags.explicitApiVersion, apiVersion != null) put(AnalysisFlags.explicitApiVersion, apiVersion != null)
put(AnalysisFlags.allowResultReturnType, allowResultReturnType) put(AnalysisFlags.allowResultReturnType, allowResultReturnType)
@@ -596,7 +596,7 @@ class FirDefaultErrorMessages {
map.put(EXPERIMENTAL_OVERRIDE, "{1}", TO_STRING, STRING) map.put(EXPERIMENTAL_OVERRIDE, "{1}", TO_STRING, STRING)
map.put(EXPERIMENTAL_OVERRIDE_ERROR, "{1}", TO_STRING, STRING) map.put(EXPERIMENTAL_OVERRIDE_ERROR, "{1}", TO_STRING, STRING)
map.put(EXPERIMENTAL_IS_NOT_ENABLED, "This class can only be used with the compiler argument '-Xopt-in=kotlin.RequiresOptIn'") map.put(EXPERIMENTAL_IS_NOT_ENABLED, "This class can only be used with the compiler argument '-opt-in=kotlin.RequiresOptIn'")
map.put(EXPERIMENTAL_CAN_ONLY_BE_USED_AS_ANNOTATION, "This class can only be used as an annotation") map.put(EXPERIMENTAL_CAN_ONLY_BE_USED_AS_ANNOTATION, "This class can only be used as an annotation")
map.put( map.put(
EXPERIMENTAL_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_USE_EXPERIMENTAL, EXPERIMENTAL_MARKER_CAN_ONLY_BE_USED_AS_ANNOTATION_OR_ARGUMENT_IN_USE_EXPERIMENTAL,
+1
View File
@@ -21,6 +21,7 @@ where possible options include:
-help (-h) Print a synopsis of standard options -help (-h) Print a synopsis of standard options
-kotlin-home <path> Path to the home directory of Kotlin compiler used for discovery of runtime libraries -kotlin-home <path> Path to the home directory of Kotlin compiler used for discovery of runtime libraries
-language-version <version> Provide source compatibility with the specified version of Kotlin -language-version <version> Provide source compatibility with the specified version of Kotlin
-opt-in <fq.name> Enable usages of API that requires opt-in with an opt-in requirement marker with the given fully qualified name
-P plugin:<pluginId>:<optionName>=<value> -P plugin:<pluginId>:<optionName>=<value>
Pass an option to a plugin Pass an option to a plugin
-progressive Enable progressive compiler mode. -progressive Enable progressive compiler mode.
@@ -1,6 +1,8 @@
$TESTDATA_DIR$/experimentalAndUseExperimentalWithSameAnnotation.kt $TESTDATA_DIR$/experimentalAndUseExperimentalWithSameAnnotation.kt
-d -d
$TEMP_DIR$ $TEMP_DIR$
-Xopt-in=kotlin.RequiresOptIn -opt-in
kotlin.RequiresOptIn
-opt-in
org.test.ExperimentalAPI
-Xexperimental=org.test.ExperimentalAPI -Xexperimental=org.test.ExperimentalAPI
-Xopt-in=org.test.ExperimentalAPI
+6 -3
View File
@@ -1,8 +1,11 @@
$TESTDATA_DIR$/experimentalDeprecated.kt $TESTDATA_DIR$/experimentalDeprecated.kt
-d -d
$TEMP_DIR$ $TEMP_DIR$
-Xopt-in=kotlin.RequiresOptIn -opt-in
kotlin.RequiresOptIn
-Xexperimental=org.test.Error1 -Xexperimental=org.test.Error1
-Xexperimental=org.test.Hidden1 -Xexperimental=org.test.Hidden1
-Xopt-in=org.test.Error2 -opt-in
-Xopt-in=org.test.Hidden2 org.test.Error2
-opt-in
org.test.Hidden2
@@ -2,6 +2,9 @@ $TESTDATA_DIR$/experimentalDeprecatedWarning.kt
-d -d
$TEMP_DIR$ $TEMP_DIR$
-Xopt-in=kotlin.RequiresOptIn -Xopt-in=kotlin.RequiresOptIn
-Xopt-in=org.test.Warning1 -opt-in
kotlin.RequiresOptIn
-opt-in
org.test.Warning1
-Xexperimental=org.test.Warning2 -Xexperimental=org.test.Warning2
-Xuse-experimental=org.test.OneMore -Xuse-experimental=org.test.OneMore
@@ -1,5 +1,6 @@
warning: '-Xexperimental' is deprecated and will be removed in a future release 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: '-Xuse-experimental' is deprecated and will be removed in a future release, please use -opt-in instead
warning: '-Xopt-in' is deprecated and will be removed in a future release, please use -opt-in instead
warning: opt-in requirement marker org.test.Warning2 is deprecated. Warning2 warning: opt-in requirement marker org.test.Warning2 is deprecated. Warning2
warning: opt-in requirement marker org.test.Warning1 is deprecated. Warning1 warning: opt-in requirement marker org.test.Warning1 is deprecated. Warning1
OK OK
+2 -1
View File
@@ -2,4 +2,5 @@ $TESTDATA_DIR$/experimentalIsNotAnnotation.kt
-d -d
$TEMP_DIR$ $TEMP_DIR$
-Xexperimental=org.test.NotAnAnnotation1 -Xexperimental=org.test.NotAnAnnotation1
-Xopt-in=org.test.NotAnAnnotation2 -opt-in
org.test.NotAnAnnotation2
+2 -1
View File
@@ -2,4 +2,5 @@ $TESTDATA_DIR$/experimentalIsNotMarker.kt
-d -d
$TEMP_DIR$ $TEMP_DIR$
-Xexperimental=org.test.NotAMarker1 -Xexperimental=org.test.NotAMarker1
-Xopt-in=org.test.NotAMarker2 -opt-in
org.test.NotAMarker2
+2 -1
View File
@@ -1,5 +1,6 @@
$TESTDATA_DIR$/experimentalNested.kt $TESTDATA_DIR$/experimentalNested.kt
-d -d
$TEMP_DIR$ $TEMP_DIR$
-Xopt-in=kotlin.RequiresOptIn -opt-in
kotlin.RequiresOptIn
-Xexperimental=org.test.Outer.Nested -Xexperimental=org.test.Outer.Nested
+5 -2
View File
@@ -1,6 +1,9 @@
$TESTDATA_DIR$/experimentalUnresolved.kt $TESTDATA_DIR$/experimentalUnresolved.kt
-d -d
$TEMP_DIR$ $TEMP_DIR$
-Xopt-in=org.test.Unresolved1 -opt-in
org.test.Unresolved1
-opt-in
org.test.Unresolved3
-Xexperimental=org.test.Unresolved2 -Xexperimental=org.test.Unresolved2
-Xopt-in=org.test.Unresolved3
+1
View File
@@ -19,6 +19,7 @@ where possible options include:
-help (-h) Print a synopsis of standard options -help (-h) Print a synopsis of standard options
-kotlin-home <path> Path to the home directory of Kotlin compiler used for discovery of runtime libraries -kotlin-home <path> Path to the home directory of Kotlin compiler used for discovery of runtime libraries
-language-version <version> Provide source compatibility with the specified version of Kotlin -language-version <version> Provide source compatibility with the specified version of Kotlin
-opt-in <fq.name> Enable usages of API that requires opt-in with an opt-in requirement marker with the given fully qualified name
-P plugin:<pluginId>:<optionName>=<value> -P plugin:<pluginId>:<optionName>=<value>
Pass an option to a plugin Pass an option to a plugin
-progressive Enable progressive compiler mode. -progressive Enable progressive compiler mode.
@@ -3,4 +3,5 @@ $TESTDATA_DIR$/useDeclarationThatWasExperimentalWithoutMarker.kt
$TEMP_DIR$ $TEMP_DIR$
-language-version -language-version
1.3 1.3
-Xopt-in=kotlin.ExperimentalStdlibApi -opt-in
kotlin.ExperimentalStdlibApi
@@ -1,5 +1,5 @@
// WITH_RUNTIME // WITH_RUNTIME
// ADDITIONAL_COMPILER_ARGUMENTS: -Xopt-in=kotlin.ExperimentalMultiplatform // ADDITIONAL_COMPILER_ARGUMENTS: -opt-in=kotlin.ExperimentalMultiplatform
@OptionalExpectation @OptionalExpectation
expect annotation class A() expect annotation class A()
@@ -1,5 +1,5 @@
// WITH_RUNTIME // WITH_RUNTIME
// ADDITIONAL_COMPILER_ARGUMENTS: -Xopt-in=kotlin.ExperimentalMultiplatform // ADDITIONAL_COMPILER_ARGUMENTS: -opt-in=kotlin.ExperimentalMultiplatform
@OptionalExpectation @OptionalExpectation
expect annotation class A() expect annotation class A()
+1 -1
View File
@@ -1,5 +1,5 @@
// "Safe delete 'Marker'" "false" // "Safe delete 'Marker'" "false"
// COMPILER_ARGUMENTS: -Xopt-in=kotlin.RequiresOptIn -Xopt-in=test.Marker // COMPILER_ARGUMENTS: -opt-in=kotlin.RequiresOptIn -opt-in=test.Marker
// WITH_RUNTIME // WITH_RUNTIME
// ACTION: Rename file to Marker.kt // ACTION: Rename file to Marker.kt
// TOOL: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection // TOOL: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection