diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirIdeSealedHierarchyProcessor.kt b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirIdeSealedHierarchyProcessor.kt
index 6357171a61e..1a0c8eb0028 100644
--- a/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirIdeSealedHierarchyProcessor.kt
+++ b/idea/idea-frontend-fir/idea-fir-low-level-api/src/org/jetbrains/kotlin/idea/fir/low/level/api/FirIdeSealedHierarchyProcessor.kt
@@ -84,6 +84,9 @@ class FirIdeSealedHierarchyProcessor(session: FirSession, scopeSession: ScopeSes
.mapNotNull { it.classIdIfNonLocal() }
.toMutableList()
+ // Enforce a deterministic order on the result.
+ subclasses.sortBy { it.toString() }
+
data[regularClass] = subclasses
}
@@ -98,4 +101,4 @@ class FirIdeSealedHierarchyProcessor(session: FirSession, scopeSession: ScopeSes
private fun getPackageViaDirectoryService(ktClass: KtClass): PsiPackage? {
val directory = ktClass.containingFile.containingDirectory ?: return null
return JavaDirectoryService.getInstance().getPackage(directory)
-}
\ No newline at end of file
+}
diff --git a/idea/testData/checker/WhenNonExhaustive.fir.kt b/idea/testData/checker/WhenNonExhaustive.fir.kt
index ca5e1c75d95..d612b7ce475 100644
--- a/idea/testData/checker/WhenNonExhaustive.fir.kt
+++ b/idea/testData/checker/WhenNonExhaustive.fir.kt
@@ -49,7 +49,7 @@ sealed class Variant {
object Another : Variant()
}
-fun nonExhaustiveSealed(v: Variant) = when(v) {
+fun nonExhaustiveSealed(v: Variant) = when(v) {
Variant.Singleton -> false
}