Skip to content

Commit c197852

Browse files
committed
Sealed classes now are decompiled correctly + test #EA-70762 Fixed
1 parent 8b325e8 commit c197852

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ enum class FlagsToModifiers {
116116
ProtoBuf.Modality.ABSTRACT -> JetTokens.ABSTRACT_KEYWORD
117117
ProtoBuf.Modality.FINAL -> JetTokens.FINAL_KEYWORD
118118
ProtoBuf.Modality.OPEN -> JetTokens.OPEN_KEYWORD
119-
else -> throw IllegalStateException("Unexpected modality: $modality")
119+
ProtoBuf.Modality.SEALED -> JetTokens.SEALED_KEYWORD
120+
null -> throw IllegalStateException("Unexpected modality: null")
120121
}
121122
}
122123
},
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package test
2+
3+
sealed class Sealed {
4+
class Nested: Sealed()
5+
object Top: Sealed()
6+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
PsiJetFileStubImpl[package=test]
2+
PACKAGE_DIRECTIVE:
3+
REFERENCE_EXPRESSION:[referencedName=test]
4+
IMPORT_LIST:
5+
CLASS:[fqName=test.Sealed, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=true, name=Sealed, superNames=[]]
6+
MODIFIER_LIST:[internal sealed]
7+
PRIMARY_CONSTRUCTOR:
8+
MODIFIER_LIST:[private]
9+
VALUE_PARAMETER_LIST:
10+
CLASS_BODY:
11+
CLASS:[fqName=test.Sealed.Nested, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=Nested, superNames=[Sealed]]
12+
MODIFIER_LIST:[internal final]
13+
PRIMARY_CONSTRUCTOR:
14+
MODIFIER_LIST:[public]
15+
VALUE_PARAMETER_LIST:
16+
DELEGATION_SPECIFIER_LIST:
17+
DELEGATOR_SUPER_CLASS:
18+
TYPE_REFERENCE:
19+
USER_TYPE:[isAbsoluteInRootPackage=false]
20+
USER_TYPE:[isAbsoluteInRootPackage=false]
21+
REFERENCE_EXPRESSION:[referencedName=test]
22+
REFERENCE_EXPRESSION:[referencedName=Sealed]
23+
CLASS_BODY:
24+
OBJECT_DECLARATION:[fqName=test.Sealed.Top, isCompanion=false, isLocal=false, isObjectLiteral=false, isTopLevel=false, name=Top, superNames=[Sealed]]
25+
MODIFIER_LIST:[internal]
26+
DELEGATION_SPECIFIER_LIST:
27+
DELEGATOR_SUPER_CLASS:
28+
TYPE_REFERENCE:
29+
USER_TYPE:[isAbsoluteInRootPackage=false]
30+
USER_TYPE:[isAbsoluteInRootPackage=false]
31+
REFERENCE_EXPRESSION:[referencedName=test]
32+
REFERENCE_EXPRESSION:[referencedName=Sealed]
33+
CLASS_BODY:

idea/tests/org/jetbrains/kotlin/idea/decompiler/stubBuilder/ClsStubBuilderTestGenerated.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ public void testPrivateToThis() throws Exception {
125125
doTest(fileName);
126126
}
127127

128+
@TestMetadata("Sealed")
129+
public void testSealed() throws Exception {
130+
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/Sealed/");
131+
doTest(fileName);
132+
}
133+
128134
@TestMetadata("SecondaryConstructors")
129135
public void testSecondaryConstructors() throws Exception {
130136
String fileName = JetTestUtils.navigationMetadata("idea/testData/decompiler/stubBuilder/SecondaryConstructors/");

0 commit comments

Comments
 (0)