diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt index 12cdb528f7d..6f1c87905d0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/deserialization/ClassDeserialization.kt @@ -51,7 +51,8 @@ fun deserializeClassToSymbol( isData = Flags.IS_DATA.get(classProto.flags) isInline = Flags.IS_INLINE_CLASS.get(classProto.flags) } - val firClass = if (modality == Modality.SEALED) { + val isSealed = modality == Modality.SEALED + val firClass = if (isSealed) { FirSealedClassImpl( null, session, @@ -131,6 +132,11 @@ fun deserializeClassToSymbol( symbol.fir } ) + + if (isSealed) { + classProto.sealedSubclassFqNameList.mapTo((firClass as FirSealedClassImpl).inheritors) { + ClassId.fromString(nameResolver.getQualifiedClassName(it)) + } + } } } - diff --git a/compiler/fir/resolve/testData/loadCompiledKotlin/class/SealedClass.txt b/compiler/fir/resolve/testData/loadCompiledKotlin/class/SealedClass.txt new file mode 100644 index 00000000000..a1cea5cef8e --- /dev/null +++ b/compiler/fir/resolve/testData/loadCompiledKotlin/class/SealedClass.txt @@ -0,0 +1,20 @@ +public final class Inheritor2 : R|test/SealedClass| { + public constructor(): R|test/Inheritor2| + +} + +public final class Inheritor3 : R|test/SealedClass| { + public constructor(): R|test/Inheritor3| + +} + +public sealed class SealedClass : R|kotlin/Any| { + private constructor(): R|test/SealedClass| + + public final class Inheritor1 : R|test/SealedClass| { + public constructor(): R|test/SealedClass.Inheritor1| + + } + +} + diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirLoadCompiledKotlinGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirLoadCompiledKotlinGenerated.java index ea9ab0e8aba..caaea28e1ed 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirLoadCompiledKotlinGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirLoadCompiledKotlinGenerated.java @@ -690,6 +690,11 @@ public class FirLoadCompiledKotlinGenerated extends AbstractFirLoadCompiledKotli runTest("compiler/testData/loadJava/compiledKotlin/class/RecursiveGeneric.kt"); } + @TestMetadata("SealedClass.kt") + public void testSealedClass() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/class/SealedClass.kt"); + } + @TestMetadata("SingleAbstractMethod.kt") public void testSingleAbstractMethod() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/class/SingleAbstractMethod.kt"); diff --git a/compiler/testData/loadJava/compiledKotlin/class/SealedClass.kt b/compiler/testData/loadJava/compiledKotlin/class/SealedClass.kt new file mode 100644 index 00000000000..fc6ef9fb6b6 --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/class/SealedClass.kt @@ -0,0 +1,9 @@ +package test + +class Inheritor3 : SealedClass() + +sealed class SealedClass { + class Inheritor1 : SealedClass() +} + +class Inheritor2 : SealedClass() \ No newline at end of file diff --git a/compiler/testData/loadJava/compiledKotlin/class/SealedClass.txt b/compiler/testData/loadJava/compiledKotlin/class/SealedClass.txt new file mode 100644 index 00000000000..0b47abf1626 --- /dev/null +++ b/compiler/testData/loadJava/compiledKotlin/class/SealedClass.txt @@ -0,0 +1,17 @@ +package test + +public final class Inheritor2 : test.SealedClass { + /*primary*/ public constructor Inheritor2() +} + +public final class Inheritor3 : test.SealedClass { + /*primary*/ public constructor Inheritor3() +} + +public sealed class SealedClass { + /*primary*/ private constructor SealedClass() + + public final class Inheritor1 : test.SealedClass { + /*primary*/ public constructor Inheritor1() + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java index 810f774c0b4..a527c21bc1a 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java @@ -2381,6 +2381,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { runTest("compiler/testData/loadJava/compiledKotlin/class/RecursiveGeneric.kt"); } + @TestMetadata("SealedClass.kt") + public void testSealedClass() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/class/SealedClass.kt"); + } + @TestMetadata("SingleAbstractMethod.kt") public void testSingleAbstractMethod() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/class/SingleAbstractMethod.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java index 039a939a500..8b4834e7e6f 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/LoadKotlinWithTypeTableTestGenerated.java @@ -690,6 +690,11 @@ public class LoadKotlinWithTypeTableTestGenerated extends AbstractLoadKotlinWith runTest("compiler/testData/loadJava/compiledKotlin/class/RecursiveGeneric.kt"); } + @TestMetadata("SealedClass.kt") + public void testSealedClass() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/class/SealedClass.kt"); + } + @TestMetadata("SingleAbstractMethod.kt") public void testSingleAbstractMethod() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/class/SingleAbstractMethod.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java index 6245f252523..9856b1b3176 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/ir/IrLoadJavaTestGenerated.java @@ -2381,6 +2381,11 @@ public class IrLoadJavaTestGenerated extends AbstractIrLoadJavaTest { runTest("compiler/testData/loadJava/compiledKotlin/class/RecursiveGeneric.kt"); } + @TestMetadata("SealedClass.kt") + public void testSealedClass() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/class/SealedClass.kt"); + } + @TestMetadata("SingleAbstractMethod.kt") public void testSingleAbstractMethod() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/class/SingleAbstractMethod.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java index cb537688623..1747aab632e 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java @@ -2381,6 +2381,11 @@ public class LoadJavaUsingJavacTestGenerated extends AbstractLoadJavaUsingJavacT runTest("compiler/testData/loadJava/compiledKotlin/class/RecursiveGeneric.kt"); } + @TestMetadata("SealedClass.kt") + public void testSealedClass() throws Exception { + runTest("compiler/testData/loadJava/compiledKotlin/class/SealedClass.kt"); + } + @TestMetadata("SingleAbstractMethod.kt") public void testSingleAbstractMethod() throws Exception { runTest("compiler/testData/loadJava/compiledKotlin/class/SingleAbstractMethod.kt");