Sort modifiers: process visibility & modality after others

Related to KT-22954
This commit is contained in:
Mikhail Glukhikh
2018-03-07 13:57:16 +03:00
parent b9e7e8fca3
commit 0c4c9251d6
3 changed files with 5 additions and 5 deletions
@@ -69,8 +69,10 @@ private class SortModifiersFix(private val modifiers: List<KtModifierKeywordToke
val owner = list.parent as? KtModifierListOwner ?: return
modifiers.forEach { owner.removeModifier(it) }
// We add visibility / modality modifiers after all others,
// because they can be redundant or not depending on others (e.g. override)
modifiers
.partition { it == KtTokens.FINAL_KEYWORD }
.partition { it in KtTokens.VISIBILITY_MODIFIERS || it in KtTokens.MODALITY_MODIFIERS }
.let { it.second + it.first }
.forEach { owner.addModifier(it) }
}