[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
-1
@@ -3,7 +3,7 @@ PsiJetFileStubImpl[package=test]
|
||||
REFERENCE_EXPRESSION[referencedName=test]
|
||||
IMPORT_LIST
|
||||
CLASS[classId=test/SealedInterface, fqName=test.SealedInterface, isEnumEntry=false, isInterface=true, isLocal=false, isTopLevel=true, name=SealedInterface, superNames=[]]
|
||||
MODIFIER_LIST[public]
|
||||
MODIFIER_LIST[public sealed]
|
||||
CLASS_BODY
|
||||
CLASS[classId=test/SealedInterface.Nested, fqName=test.SealedInterface.Nested, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=Nested, superNames=[SealedInterface]]
|
||||
MODIFIER_LIST[public final]
|
||||
|
||||
+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)
|
||||
|
||||
@@ -17,7 +17,7 @@ object KotlinStubVersions {
|
||||
// Binary stub version should be increased if stub format (org.jetbrains.kotlin.psi.stubs.impl) is changed
|
||||
// or changes are made to the core stub building code (org.jetbrains.kotlin.idea.decompiler.stubBuilder).
|
||||
// Increasing this version will lead to reindexing of all binary files that are potentially kotlin binaries (including all class files).
|
||||
private const val BINARY_STUB_VERSION = 94
|
||||
private const val BINARY_STUB_VERSION = 95
|
||||
|
||||
// Classfile stub version should be increased if changes are made to classfile stub building subsystem (org.jetbrains.kotlin.idea.decompiler.classFile)
|
||||
// Increasing this version will lead to reindexing of all classfiles.
|
||||
|
||||
Reference in New Issue
Block a user