Cleanup: LanguageFeature.defaultState -> LanguageFeature.isEnabledWithWarning

Review: https://jetbrains.team/p/kt/reviews/7418

`State` enum contains `DISABLED` item which is redundant for
`LanguageFeature`. It's redundant because `sinceVersion = null` is used
to express the same semantic.

I had to reorder some items in the enum because otherwise
`testLanguageFeatureOrder` fails. I could keep the same logic in
`testLanguageFeatureOrder` but I would need to make
`isEnabledWithWarning` public which I don't want to. Anyway, it's not
obvious what is more readable: keep `isEnabledWithWarning = true` items
at the end or at the beginning.

Also all effectively disabled features (`sinceVersion = null` or
`defaultState = State.DISABLED`) are now moved to the "Experimental"
section at the end which is obviously better.
This commit is contained in:
Nikita Bobko
2022-10-17 13:32:22 +02:00
parent 49a5186f15
commit cdbfcdc465
2 changed files with 40 additions and 38 deletions
@@ -393,7 +393,7 @@ class CodeConformanceTest : TestCase() {
fun testLanguageFeatureOrder() {
val values = enumValues<LanguageFeature>()
val enabledFeatures = values.filter { it.sinceVersion != null && it.defaultState == LanguageFeature.State.ENABLED }
val enabledFeatures = values.filter { it.sinceVersion != null }
if (enabledFeatures.sortedBy { it.sinceVersion!! } != enabledFeatures) {
val (a, b) = enabledFeatures.zipWithNext().first { (a, b) -> a.sinceVersion!! > b.sinceVersion!! }