Write/load subclasses of sealed classes in metadata
Note that now DeserializedClassDescriptor.getSealedSubclasses works a lot faster than before, for all newly compiled sealed classes except empty ones. It may be optimized further if we look at the metadata version of the file the class was loaded from, however it's not easy currently because DeserializedClassDescriptor is declared in common (non-JVM) code and has no direct access to the binary version information. This will also allow to add a reflection API to get subclasses of a sealed class #KT-12795 Fixed
This commit is contained in:
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils.isEnumEntry
|
||||
import org.jetbrains.kotlin.resolve.MemberComparator
|
||||
import org.jetbrains.kotlin.resolve.constants.NullValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.utils.Interner
|
||||
import java.io.ByteArrayOutputStream
|
||||
@@ -116,6 +117,10 @@ class DescriptorSerializer private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
for (sealedSubclass in classDescriptor.sealedSubclasses) {
|
||||
builder.addSealedSubclassFqName(getClassifierId(sealedSubclass))
|
||||
}
|
||||
|
||||
val companionObjectDescriptor = classDescriptor.companionObjectDescriptor
|
||||
if (companionObjectDescriptor != null) {
|
||||
builder.companionObjectName = getSimpleNameIndex(companionObjectDescriptor.name)
|
||||
|
||||
Reference in New Issue
Block a user