Reorder LanguageFeature entries according to sinceVersion
This commit is contained in:
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.code
|
|||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import com.intellij.openapi.util.io.systemIndependentPath
|
import com.intellij.openapi.util.io.systemIndependentPath
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
@@ -379,6 +380,20 @@ class CodeConformanceTest : TestCase() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testLanguageFeatureOrder() {
|
||||||
|
val values = enumValues<LanguageFeature>()
|
||||||
|
val enabledFeatures = values.filter { it.sinceVersion != null && it.defaultState == LanguageFeature.State.ENABLED }
|
||||||
|
|
||||||
|
if (enabledFeatures.sortedBy { it.sinceVersion!! } != enabledFeatures) {
|
||||||
|
val (a, b) = enabledFeatures.zipWithNext().first { (a, b) -> a.sinceVersion!! > b.sinceVersion!! }
|
||||||
|
fail(
|
||||||
|
"Please make sure LanguageFeature entries are sorted by sinceVersion to improve readability & reduce confusion.\n" +
|
||||||
|
"The feature $b is out of order; its sinceVersion is ${b.sinceVersion}, yet it comes after $a, whose " +
|
||||||
|
"sinceVersion is ${a.sinceVersion}.\n"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.ensureFileOrEndsWithSlash() =
|
private fun String.ensureFileOrEndsWithSlash() =
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ enum class LanguageFeature(
|
|||||||
val kind: Kind = OTHER // NB: default value OTHER doesn't force pre-releaseness (see KDoc)
|
val kind: Kind = OTHER // NB: default value OTHER doesn't force pre-releaseness (see KDoc)
|
||||||
) {
|
) {
|
||||||
// Note: names of these entries are also used in diagnostic tests and in user-visible messages (see presentableText below)
|
// Note: names of these entries are also used in diagnostic tests and in user-visible messages (see presentableText below)
|
||||||
|
|
||||||
|
// 1.1
|
||||||
|
|
||||||
TypeAliases(KOTLIN_1_1),
|
TypeAliases(KOTLIN_1_1),
|
||||||
BoundCallableReferences(KOTLIN_1_1, ApiVersion.KOTLIN_1_1),
|
BoundCallableReferences(KOTLIN_1_1, ApiVersion.KOTLIN_1_1),
|
||||||
LocalDelegatedProperties(KOTLIN_1_1, ApiVersion.KOTLIN_1_1),
|
LocalDelegatedProperties(KOTLIN_1_1, ApiVersion.KOTLIN_1_1),
|
||||||
@@ -40,6 +43,8 @@ enum class LanguageFeature(
|
|||||||
NoDelegationToJavaDefaultInterfaceMembers(KOTLIN_1_1),
|
NoDelegationToJavaDefaultInterfaceMembers(KOTLIN_1_1),
|
||||||
DefaultImportOfPackageKotlinComparisons(KOTLIN_1_1),
|
DefaultImportOfPackageKotlinComparisons(KOTLIN_1_1),
|
||||||
|
|
||||||
|
// 1.2
|
||||||
|
|
||||||
ArrayLiteralsInAnnotations(KOTLIN_1_2),
|
ArrayLiteralsInAnnotations(KOTLIN_1_2),
|
||||||
InlineDefaultFunctionalParameters(KOTLIN_1_2),
|
InlineDefaultFunctionalParameters(KOTLIN_1_2),
|
||||||
SoundSmartCastsAfterTry(KOTLIN_1_2),
|
SoundSmartCastsAfterTry(KOTLIN_1_2),
|
||||||
@@ -57,6 +62,8 @@ enum class LanguageFeature(
|
|||||||
ExpectedTypeFromCast(KOTLIN_1_2),
|
ExpectedTypeFromCast(KOTLIN_1_2),
|
||||||
DefaultMethodsCallFromJava6TargetError(KOTLIN_1_2),
|
DefaultMethodsCallFromJava6TargetError(KOTLIN_1_2),
|
||||||
|
|
||||||
|
// 1.3
|
||||||
|
|
||||||
RestrictionOfValReassignmentViaBackingField(KOTLIN_1_3, kind = BUG_FIX),
|
RestrictionOfValReassignmentViaBackingField(KOTLIN_1_3, kind = BUG_FIX),
|
||||||
NestedClassesInEnumEntryShouldBeInner(KOTLIN_1_3, kind = BUG_FIX),
|
NestedClassesInEnumEntryShouldBeInner(KOTLIN_1_3, kind = BUG_FIX),
|
||||||
ProhibitDataClassesOverridingCopy(KOTLIN_1_3, kind = BUG_FIX),
|
ProhibitDataClassesOverridingCopy(KOTLIN_1_3, kind = BUG_FIX),
|
||||||
@@ -88,6 +95,8 @@ enum class LanguageFeature(
|
|||||||
ExtendedMainConvention(KOTLIN_1_3),
|
ExtendedMainConvention(KOTLIN_1_3),
|
||||||
ExperimentalBuilderInference(KOTLIN_1_3),
|
ExperimentalBuilderInference(KOTLIN_1_3),
|
||||||
|
|
||||||
|
// 1.4
|
||||||
|
|
||||||
DslMarkerOnFunctionTypeReceiver(KOTLIN_1_4, kind = BUG_FIX),
|
DslMarkerOnFunctionTypeReceiver(KOTLIN_1_4, kind = BUG_FIX),
|
||||||
RestrictReturnStatementTarget(KOTLIN_1_4, kind = BUG_FIX),
|
RestrictReturnStatementTarget(KOTLIN_1_4, kind = BUG_FIX),
|
||||||
NoConstantValueAttributeForNonConstVals(KOTLIN_1_4, kind = BUG_FIX),
|
NoConstantValueAttributeForNonConstVals(KOTLIN_1_4, kind = BUG_FIX),
|
||||||
@@ -116,7 +125,6 @@ enum class LanguageFeature(
|
|||||||
AllowAssigningArrayElementsToVarargsInNamedFormForFunctions(KOTLIN_1_4),
|
AllowAssigningArrayElementsToVarargsInNamedFormForFunctions(KOTLIN_1_4),
|
||||||
AllowNullOperatorsForResult(KOTLIN_1_4),
|
AllowNullOperatorsForResult(KOTLIN_1_4),
|
||||||
AllowResultInReturnType(KOTLIN_1_4, defaultState = State.DISABLED),
|
AllowResultInReturnType(KOTLIN_1_4, defaultState = State.DISABLED),
|
||||||
AllowNullOperatorsForResultAndResultReturnTypeByDefault(KOTLIN_1_5, defaultState = State.ENABLED),
|
|
||||||
PreferJavaFieldOverload(KOTLIN_1_4),
|
PreferJavaFieldOverload(KOTLIN_1_4),
|
||||||
AllowContractsForNonOverridableMembers(KOTLIN_1_4),
|
AllowContractsForNonOverridableMembers(KOTLIN_1_4),
|
||||||
AllowReifiedGenericsInContracts(KOTLIN_1_4),
|
AllowReifiedGenericsInContracts(KOTLIN_1_4),
|
||||||
@@ -128,27 +136,51 @@ enum class LanguageFeature(
|
|||||||
MangleClassMembersReturningInlineClasses(KOTLIN_1_4),
|
MangleClassMembersReturningInlineClasses(KOTLIN_1_4),
|
||||||
ImproveReportingDiagnosticsOnProtectedMembersOfBaseClass(KOTLIN_1_4, kind = BUG_FIX, defaultState = State.ENABLED),
|
ImproveReportingDiagnosticsOnProtectedMembersOfBaseClass(KOTLIN_1_4, kind = BUG_FIX, defaultState = State.ENABLED),
|
||||||
|
|
||||||
|
NewInference(KOTLIN_1_4),
|
||||||
|
|
||||||
|
// In the next block, features can be enabled only along with new inference
|
||||||
|
// v----------------------------------------------------------------------v
|
||||||
|
SamConversionForKotlinFunctions(KOTLIN_1_4),
|
||||||
|
SamConversionPerArgument(KOTLIN_1_4),
|
||||||
|
FunctionReferenceWithDefaultValueAsOtherType(KOTLIN_1_4),
|
||||||
|
SuspendConversion(KOTLIN_1_4, defaultState = State.DISABLED),
|
||||||
|
UnitConversion(KOTLIN_1_4, defaultState = State.DISABLED),
|
||||||
|
OverloadResolutionByLambdaReturnType(KOTLIN_1_4),
|
||||||
|
ContractsOnCallsWithImplicitReceiver(KOTLIN_1_4),
|
||||||
|
BooleanElvisBoundSmartCasts(KOTLIN_1_3, defaultState = State.DISABLED), // see KT-26357 for details
|
||||||
|
NewDataFlowForTryExpressions(KOTLIN_1_4, defaultState = State.DISABLED),
|
||||||
|
ReferencesToSyntheticJavaProperties(KOTLIN_1_3, defaultState = State.DISABLED),
|
||||||
|
// ^----------------------------------------------------------------------^
|
||||||
|
|
||||||
|
// 1.5
|
||||||
|
|
||||||
ProhibitSpreadOnSignaturePolymorphicCall(KOTLIN_1_5, kind = BUG_FIX),
|
ProhibitSpreadOnSignaturePolymorphicCall(KOTLIN_1_5, kind = BUG_FIX),
|
||||||
ProhibitInvisibleAbstractMethodsInSuperclasses(KOTLIN_1_5, kind = BUG_FIX),
|
ProhibitInvisibleAbstractMethodsInSuperclasses(KOTLIN_1_5, kind = BUG_FIX),
|
||||||
ProhibitNonReifiedArraysAsReifiedTypeArguments(KOTLIN_1_5, kind = BUG_FIX),
|
ProhibitNonReifiedArraysAsReifiedTypeArguments(KOTLIN_1_5, kind = BUG_FIX),
|
||||||
ProhibitVarargAsArrayAfterSamArgument(KOTLIN_1_5, kind = BUG_FIX),
|
ProhibitVarargAsArrayAfterSamArgument(KOTLIN_1_5, kind = BUG_FIX),
|
||||||
CorrectSourceMappingSyntax(KOTLIN_1_5, kind = UNSTABLE_FEATURE),
|
CorrectSourceMappingSyntax(KOTLIN_1_5, kind = UNSTABLE_FEATURE),
|
||||||
ProperArrayConventionSetterWithDefaultCalls(KOTLIN_1_5, kind = OTHER),
|
ProperArrayConventionSetterWithDefaultCalls(KOTLIN_1_5, kind = OTHER),
|
||||||
DisableCompatibilityModeForNewInference(KOTLIN_1_5, defaultState = LanguageFeature.State.DISABLED),
|
DisableCompatibilityModeForNewInference(KOTLIN_1_5, defaultState = State.DISABLED),
|
||||||
AdaptedCallableReferenceAgainstReflectiveType(KOTLIN_1_5, defaultState = LanguageFeature.State.DISABLED),
|
AdaptedCallableReferenceAgainstReflectiveType(KOTLIN_1_5, defaultState = State.DISABLED),
|
||||||
InferenceCompatibility(KOTLIN_1_5, kind = BUG_FIX),
|
InferenceCompatibility(KOTLIN_1_5, kind = BUG_FIX),
|
||||||
RequiredPrimaryConstructorDelegationCallInEnums(KOTLIN_1_5, kind = BUG_FIX),
|
RequiredPrimaryConstructorDelegationCallInEnums(KOTLIN_1_5, kind = BUG_FIX),
|
||||||
ApproximateAnonymousReturnTypesInPrivateInlineFunctions(KOTLIN_1_5, kind = BUG_FIX),
|
ApproximateAnonymousReturnTypesInPrivateInlineFunctions(KOTLIN_1_5, kind = BUG_FIX),
|
||||||
ForbidReferencingToUnderscoreNamedParameterOfCatchBlock(KOTLIN_1_5, kind = BUG_FIX),
|
ForbidReferencingToUnderscoreNamedParameterOfCatchBlock(KOTLIN_1_5, kind = BUG_FIX),
|
||||||
UseCorrectExecutionOrderForVarargArguments(KOTLIN_1_5, kind = BUG_FIX),
|
UseCorrectExecutionOrderForVarargArguments(KOTLIN_1_5, kind = BUG_FIX),
|
||||||
JvmRecordSupport(KOTLIN_1_5),
|
JvmRecordSupport(KOTLIN_1_5),
|
||||||
|
AllowNullOperatorsForResultAndResultReturnTypeByDefault(KOTLIN_1_5, defaultState = State.ENABLED),
|
||||||
AllowSealedInheritorsInDifferentFilesOfSamePackage(KOTLIN_1_5),
|
AllowSealedInheritorsInDifferentFilesOfSamePackage(KOTLIN_1_5),
|
||||||
SealedInterfaces(KOTLIN_1_5),
|
SealedInterfaces(KOTLIN_1_5),
|
||||||
JvmIrEnabledByDefault(KOTLIN_1_5),
|
JvmIrEnabledByDefault(KOTLIN_1_5),
|
||||||
|
JvmInlineValueClasses(KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER),
|
||||||
|
SuspendFunctionsInFunInterfaces(KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER),
|
||||||
|
SamWrapperClassesAreSynthetic(KOTLIN_1_5, defaultState = State.ENABLED, kind = BUG_FIX),
|
||||||
|
StrictOnlyInputTypesChecks(KOTLIN_1_5),
|
||||||
|
|
||||||
// Disabled until the breaking change is approved by the committee, see KT-10884.
|
// Disabled until the breaking change is approved by the committee, see KT-10884.
|
||||||
PackagePrivateFileClassesWithAllPrivateMembers(KOTLIN_1_5, defaultState = State.DISABLED),
|
PackagePrivateFileClassesWithAllPrivateMembers(KOTLIN_1_5, defaultState = State.DISABLED),
|
||||||
StrictOnlyInputTypesChecks(sinceVersion = KOTLIN_1_5),
|
|
||||||
|
// 1.6
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Improvements include the following:
|
* Improvements include the following:
|
||||||
@@ -170,6 +202,9 @@ enum class LanguageFeature(
|
|||||||
ApproximateIntegerLiteralTypesInReceiverPosition(KOTLIN_1_6),
|
ApproximateIntegerLiteralTypesInReceiverPosition(KOTLIN_1_6),
|
||||||
ProperCheckAnnotationsTargetInTypeUsePositions(KOTLIN_1_6, kind = BUG_FIX),
|
ProperCheckAnnotationsTargetInTypeUsePositions(KOTLIN_1_6, kind = BUG_FIX),
|
||||||
|
|
||||||
|
DefinitelyNotNullTypeParameters(KOTLIN_1_6),
|
||||||
|
ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated(KOTLIN_1_6, kind = BUG_FIX),
|
||||||
|
|
||||||
// Temporarily disabled, see KT-27084/KT-22379
|
// Temporarily disabled, see KT-27084/KT-22379
|
||||||
SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX),
|
SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX),
|
||||||
|
|
||||||
@@ -180,38 +215,13 @@ enum class LanguageFeature(
|
|||||||
"https://kotlinlang.org/docs/diagnostics/experimental-coroutines",
|
"https://kotlinlang.org/docs/diagnostics/experimental-coroutines",
|
||||||
State.ENABLED_WITH_WARNING
|
State.ENABLED_WITH_WARNING
|
||||||
),
|
),
|
||||||
|
|
||||||
MultiPlatformProjects(sinceVersion = null, defaultState = State.DISABLED),
|
MultiPlatformProjects(sinceVersion = null, defaultState = State.DISABLED),
|
||||||
|
InlineClasses(KOTLIN_1_3, defaultState = State.ENABLED_WITH_WARNING, kind = UNSTABLE_FEATURE),
|
||||||
|
|
||||||
NewInference(sinceVersion = KOTLIN_1_4),
|
|
||||||
|
|
||||||
// In the next block, features can be enabled only along with new inference
|
|
||||||
SamConversionForKotlinFunctions(sinceVersion = KOTLIN_1_4),
|
|
||||||
SamConversionPerArgument(sinceVersion = KOTLIN_1_4),
|
|
||||||
FunctionReferenceWithDefaultValueAsOtherType(sinceVersion = KOTLIN_1_4),
|
|
||||||
SuspendConversion(sinceVersion = KOTLIN_1_4, defaultState = State.DISABLED),
|
|
||||||
UnitConversion(sinceVersion = KOTLIN_1_4, defaultState = State.DISABLED),
|
|
||||||
OverloadResolutionByLambdaReturnType(sinceVersion = KOTLIN_1_4),
|
|
||||||
ContractsOnCallsWithImplicitReceiver(sinceVersion = KOTLIN_1_4),
|
|
||||||
|
|
||||||
BooleanElvisBoundSmartCasts(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), // see KT-26357 for details
|
|
||||||
NewDataFlowForTryExpressions(sinceVersion = KOTLIN_1_4, defaultState = State.DISABLED),
|
|
||||||
ReferencesToSyntheticJavaProperties(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED),
|
|
||||||
// ------
|
|
||||||
// Next features can be enabled regardless of new inference
|
|
||||||
|
|
||||||
InlineClasses(sinceVersion = KOTLIN_1_3, defaultState = State.ENABLED_WITH_WARNING, kind = UNSTABLE_FEATURE),
|
|
||||||
JvmInlineValueClasses(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER),
|
|
||||||
SuspendFunctionsInFunInterfaces(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER),
|
|
||||||
SamWrapperClassesAreSynthetic(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = BUG_FIX),
|
|
||||||
|
|
||||||
// 1.6
|
|
||||||
DefinitelyNotNullTypeParameters(sinceVersion = KOTLIN_1_6),
|
|
||||||
ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated(sinceVersion = KOTLIN_1_6, kind = BUG_FIX),
|
|
||||||
;
|
;
|
||||||
|
|
||||||
val presentableName: String
|
val presentableName: String
|
||||||
// E.g. "DestructuringLambdaParameters" -> ["Destructuring", "Lambda", "Parameters"] -> "destructuring lambda parameters"
|
// E.g. "DestructuringLambdaParameters" -> ["Destructuring", "Lambda", "Parameters"] -> "destructuring lambda parameters"
|
||||||
get() = name.split("(?<!^)(?=[A-Z])".toRegex()).joinToString(separator = " ", transform = String::lowercase)
|
get() = name.split("(?<!^)(?=[A-Z])".toRegex()).joinToString(separator = " ", transform = String::lowercase)
|
||||||
|
|
||||||
val presentableText get() = if (hintUrl == null) presentableName else "$presentableName (See: $hintUrl)"
|
val presentableText get() = if (hintUrl == null) presentableName else "$presentableName (See: $hintUrl)"
|
||||||
@@ -345,7 +355,7 @@ interface LanguageVersionSettings {
|
|||||||
fun supportsFeature(feature: LanguageFeature): Boolean =
|
fun supportsFeature(feature: LanguageFeature): Boolean =
|
||||||
getFeatureSupport(feature).let {
|
getFeatureSupport(feature).let {
|
||||||
it == LanguageFeature.State.ENABLED ||
|
it == LanguageFeature.State.ENABLED ||
|
||||||
it == LanguageFeature.State.ENABLED_WITH_WARNING
|
it == LanguageFeature.State.ENABLED_WITH_WARNING
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isPreRelease(): Boolean
|
fun isPreRelease(): Boolean
|
||||||
|
|||||||
Reference in New Issue
Block a user