[Compiler CLI] Sort flags and features before appending them to string

JS IR BE incremental compilation infrastructure uses
 LanguageVersionSettings::toString method to detect if any
 compiler features or flags were enabled or disabled.
 It is important that the features and flags order are stable
 in the result string.

^KT-56580 Fixed
This commit is contained in:
Alexander Korepanov
2023-02-14 12:38:56 +01:00
committed by Space Team
parent df450ac43c
commit 43cef114c6
9 changed files with 69 additions and 2 deletions
@@ -538,7 +538,7 @@ class LanguageVersionSettingsImpl @JvmOverloads constructor(
override fun toString() = buildString {
append("Language = $languageVersion, API = $apiVersion")
specificFeatures.forEach { (feature, state) ->
specificFeatures.entries.sortedBy { (feature, _) -> feature.ordinal }.forEach { (feature, state) ->
val char = when (state) {
LanguageFeature.State.ENABLED -> '+'
LanguageFeature.State.ENABLED_WITH_WARNING -> '~'
@@ -546,7 +546,7 @@ class LanguageVersionSettingsImpl @JvmOverloads constructor(
}
append(" $char$feature")
}
analysisFlags.forEach { (flag, value) ->
analysisFlags.entries.sortedBy { (flag, _) -> flag.toString() }.forEach { (flag, value) ->
append(" $flag:$value")
}
}