[AA decompiler] Store sealed modifiers in interface stubs
- If the `sealed` modifier is not kept in the interface's stub, a sealed interface will have an `abstract` modality instead, which causes issues with `when` exhaustiveness analysis in K2. - This issue also affected K1, but it was less visible there because `when` exhaustiveness analysis in K1 uses deserialized descriptors. ^KT-62895
This commit is contained in:
committed by
Space Team
parent
5797b4877c
commit
bace053ea9
+1
@@ -103,6 +103,7 @@ private class ClassClsStubBuilder(
|
||||
}
|
||||
if (isInterface()) {
|
||||
relevantFlags.add(FUN_INTERFACE)
|
||||
relevantFlags.add(INTERFACE_MODALITY)
|
||||
}
|
||||
val additionalModifiers = when (classKind) {
|
||||
ProtoBuf.Class.Kind.ENUM_CLASS -> listOf(KtTokens.ENUM_KEYWORD)
|
||||
|
||||
+10
@@ -24,6 +24,16 @@ val MODALITY: FlagsToModifiers = object : FlagsToModifiers() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For interfaces, we only need to remember a `sealed` modifier in the stub, as the interface will be abstract by default.
|
||||
*/
|
||||
val INTERFACE_MODALITY: FlagsToModifiers = object : FlagsToModifiers() {
|
||||
override fun getModifiers(flags: Int): KtModifierKeywordToken? {
|
||||
val modality = Flags.MODALITY.get(flags)
|
||||
return KtTokens.SEALED_KEYWORD.takeIf { modality == ProtoBuf.Modality.SEALED }
|
||||
}
|
||||
}
|
||||
|
||||
val VISIBILITY: FlagsToModifiers = object : FlagsToModifiers() {
|
||||
override fun getModifiers(flags: Int): KtModifierKeywordToken? {
|
||||
val visibility = Flags.VISIBILITY.get(flags)
|
||||
|
||||
Reference in New Issue
Block a user