Introduce -Xprogressive
This commit is contained in:
+26
@@ -160,6 +160,16 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
var dumpPerf: String? by FreezableVar(null)
|
||||
|
||||
@Argument(
|
||||
value = "-Xprogressive",
|
||||
description = "Enable compiler progressive mode.\n" +
|
||||
"In this mode, deprecations and bug fixes for unstable code take effect immediately,\n" +
|
||||
"instead of going through graceful migration cycle.\n" +
|
||||
"Code, written in progressive mode is backward compatible; however, code written in\n" +
|
||||
"non-progressive mode may cause compilation errors in progressive mode."
|
||||
)
|
||||
var progressiveMode by FreezableVar(false)
|
||||
|
||||
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||
return HashMap<AnalysisFlag<*>, Any>().apply {
|
||||
put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
||||
@@ -207,6 +217,14 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
if (properIeee754Comparisons) {
|
||||
put(LanguageFeature.ProperIeee754Comparisons, LanguageFeature.State.ENABLED)
|
||||
}
|
||||
|
||||
if (progressiveMode) {
|
||||
LanguageFeature.values().filter { it.enabledInProgressiveMode }.forEach {
|
||||
// Don't overwrite other settings: users may want to turn off some particular
|
||||
// breaking change manually instead of turning off whole progressive mode
|
||||
if (!contains(it)) put(it, LanguageFeature.State.ENABLED)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun configureLanguageVersionSettings(collector: MessageCollector): LanguageVersionSettings {
|
||||
@@ -232,6 +250,14 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
}
|
||||
|
||||
if (progressiveMode && languageVersion < LanguageVersion.LATEST_STABLE) {
|
||||
collector.report(
|
||||
CompilerMessageSeverity.STRONG_WARNING,
|
||||
"'-Xprogressive' meaningful only for latest language version (${LanguageVersion.LATEST_STABLE}), while this build uses $languageVersion\n" +
|
||||
"Behaviour of compiler in such mode is undefined; please, consider moving to the latest stable version or turning off progressive mode."
|
||||
)
|
||||
}
|
||||
|
||||
return LanguageVersionSettingsImpl(
|
||||
languageVersion,
|
||||
ApiVersion.createByLanguageVersion(apiVersion),
|
||||
|
||||
+5
@@ -16,6 +16,11 @@ where advanced options include:
|
||||
-Xno-check-actual Do not check presence of 'actual' modifier in multi-platform projects
|
||||
-Xno-inline Disable method inlining
|
||||
-Xplugin=<path> Load plugins from the given classpath
|
||||
-Xprogressive Enable compiler progressive mode.
|
||||
In this mode, deprecations and bug fixes for unstable code take effect immediately,
|
||||
instead of going through graceful migration cycle.
|
||||
Code, written in progressive mode is backward compatible; however, code written in
|
||||
non-progressive mode may cause compilation errors in progressive mode.
|
||||
-Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types
|
||||
-Xread-deserialized-contracts Enable reading of contracts from metadata
|
||||
-Xreport-output-files Report source to output files mapping
|
||||
|
||||
+5
@@ -58,6 +58,11 @@ where advanced options include:
|
||||
-Xno-check-actual Do not check presence of 'actual' modifier in multi-platform projects
|
||||
-Xno-inline Disable method inlining
|
||||
-Xplugin=<path> Load plugins from the given classpath
|
||||
-Xprogressive Enable compiler progressive mode.
|
||||
In this mode, deprecations and bug fixes for unstable code take effect immediately,
|
||||
instead of going through graceful migration cycle.
|
||||
Code, written in progressive mode is backward compatible; however, code written in
|
||||
non-progressive mode may cause compilation errors in progressive mode.
|
||||
-Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types
|
||||
-Xread-deserialized-contracts Enable reading of contracts from metadata
|
||||
-Xreport-output-files Report source to output files mapping
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
interface WithCopy<T> {
|
||||
fun copy(str: T): WithCopy<T>
|
||||
}
|
||||
|
||||
data class Test(val str: String): WithCopy<String>
|
||||
@@ -0,0 +1,6 @@
|
||||
val nonConstArray = longArrayOf(0)
|
||||
|
||||
annotation class Anno(vararg val value: Long)
|
||||
|
||||
@Anno(value = nonConstArray)
|
||||
fun foo1() {}
|
||||
@@ -0,0 +1,5 @@
|
||||
val my: Int = 1
|
||||
get() {
|
||||
field++
|
||||
return field
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
$TESTDATA_DIR$/progressive
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
@@ -0,0 +1,10 @@
|
||||
compiler/testData/cli/jvm/progressive/dataClassOverridingCopy.kt:5:1: warning: function 'copy' generated for the data class has default values for parameters, and conflicts with member of supertype 'WithCopy'
|
||||
data class Test(val str: String): WithCopy<String>
|
||||
^
|
||||
compiler/testData/cli/jvm/progressive/nonConstValueAsVarargInAnnotation.kt:5:15: warning: an annotation argument must be a compile-time constant
|
||||
@Anno(value = nonConstArray)
|
||||
^
|
||||
compiler/testData/cli/jvm/progressive/valReassignmentViaBackingField.kt:3:9: warning: reassignment of read-only property via backing field is deprecated
|
||||
field++
|
||||
^
|
||||
OK
|
||||
@@ -0,0 +1,4 @@
|
||||
$TESTDATA_DIR$/progressive
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xprogressive
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
compiler/testData/cli/jvm/progressive/dataClassOverridingCopy.kt:5:1: error: function 'copy' generated for the data class has default values for parameters, and conflicts with member of supertype 'WithCopy'
|
||||
data class Test(val str: String): WithCopy<String>
|
||||
^
|
||||
compiler/testData/cli/jvm/progressive/nonConstValueAsVarargInAnnotation.kt:5:15: error: an annotation argument must be a compile-time constant
|
||||
@Anno(value = nonConstArray)
|
||||
^
|
||||
compiler/testData/cli/jvm/progressive/valReassignmentViaBackingField.kt:3:9: error: reassignment of read-only property via backing field
|
||||
field++
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
@@ -397,6 +397,18 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/pluginSimple.args");
|
||||
}
|
||||
|
||||
@TestMetadata("progressiveModeOff.args")
|
||||
public void testProgressiveModeOff() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/progressiveModeOff.args");
|
||||
doJvmTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("progressiveModeOn.args")
|
||||
public void testProgressiveModeOn() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/progressiveModeOn.args");
|
||||
doJvmTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("returnAsWhenKey.args")
|
||||
public void testReturnAsWhenKey() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/returnAsWhenKey.args");
|
||||
|
||||
@@ -13,7 +13,8 @@ enum class LanguageFeature(
|
||||
val sinceVersion: LanguageVersion?,
|
||||
val sinceApiVersion: ApiVersion = ApiVersion.KOTLIN_1_0,
|
||||
val hintUrl: String? = null,
|
||||
val defaultState: State = State.ENABLED
|
||||
val defaultState: State = State.ENABLED,
|
||||
val enabledInProgressiveMode: Boolean = false
|
||||
) {
|
||||
// Note: names of these entries are also used in diagnostic tests and in user-visible messages (see presentableText below)
|
||||
TypeAliases(KOTLIN_1_1),
|
||||
@@ -56,23 +57,23 @@ enum class LanguageFeature(
|
||||
DefaultMethodsCallFromJava6TargetError(KOTLIN_1_2),
|
||||
|
||||
BooleanElvisBoundSmartCasts(KOTLIN_1_3),
|
||||
RestrictionOfValReassignmentViaBackingField(KOTLIN_1_3),
|
||||
NestedClassesInEnumEntryShouldBeInner(KOTLIN_1_3),
|
||||
ProhibitDataClassesOverridingCopy(KOTLIN_1_3),
|
||||
RestrictionOfWrongAnnotationsWithUseSiteTargetsOnTypes(KOTLIN_1_3),
|
||||
ProhibitInnerClassesOfGenericClassExtendingThrowable(KOTLIN_1_3),
|
||||
ProperVisibilityForCompanionObjectInstanceField(KOTLIN_1_3),
|
||||
ProperForInArrayLoopRangeVariableAssignmentSemantic(KOTLIN_1_3),
|
||||
RestrictionOfValReassignmentViaBackingField(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
NestedClassesInEnumEntryShouldBeInner(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
ProhibitDataClassesOverridingCopy(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
RestrictionOfWrongAnnotationsWithUseSiteTargetsOnTypes(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
ProhibitInnerClassesOfGenericClassExtendingThrowable(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
ProperVisibilityForCompanionObjectInstanceField(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
ProperForInArrayLoopRangeVariableAssignmentSemantic(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
NestedClassesInAnnotations(KOTLIN_1_3),
|
||||
JvmStaticInInterface(KOTLIN_1_3),
|
||||
ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion(KOTLIN_1_3),
|
||||
ProhibitNonConstValuesAsVarargsInAnnotations(KOTLIN_1_3),
|
||||
ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
ProhibitNonConstValuesAsVarargsInAnnotations(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
ReleaseCoroutines(KOTLIN_1_3),
|
||||
ReadDeserializedContracts(KOTLIN_1_3),
|
||||
UseReturnsEffect(KOTLIN_1_3),
|
||||
UseCallsInPlaceEffect(KOTLIN_1_3),
|
||||
AllowContractsForCustomFunctions(KOTLIN_1_3),
|
||||
ProhibitLocalAnnotations(KOTLIN_1_3),
|
||||
ProhibitLocalAnnotations(KOTLIN_1_3, enabledInProgressiveMode = true),
|
||||
|
||||
StrictJavaNullabilityAssertions(sinceVersion = null, defaultState = State.DISABLED),
|
||||
ProperIeee754Comparisons(sinceVersion = null, defaultState = State.DISABLED),
|
||||
|
||||
Reference in New Issue
Block a user