[FIR] Add deserialization of inheritors of sealed classes

This commit is contained in:
Dmitriy Novozhilov
2019-10-17 11:37:43 +03:00
parent 3dc49ab1d4
commit 25e853606e
9 changed files with 79 additions and 2 deletions
@@ -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))
}
}
}
}
@@ -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|
}
}
@@ -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");
@@ -0,0 +1,9 @@
package test
class Inheritor3 : SealedClass()
sealed class SealedClass {
class Inheritor1 : SealedClass()
}
class Inheritor2 : SealedClass()
@@ -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()
}
}
@@ -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");
@@ -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");
@@ -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");
@@ -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");