ClassDescriptor is now a super-interface for ClassConstructorDescriptor and TypeAliasConstructorDescriptor.
This commit is contained in:
committed by
Dmitry Petrov
parent
7d214c6e58
commit
796d11c860
+3
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -25,13 +26,13 @@ import org.jetbrains.kotlin.types.KotlinType
|
||||
interface AdditionalClassPartsProvider {
|
||||
fun getSupertypes(classDescriptor: DeserializedClassDescriptor): Collection<KotlinType>
|
||||
fun getFunctions(name: Name, classDescriptor: DeserializedClassDescriptor): Collection<SimpleFunctionDescriptor>
|
||||
fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ConstructorDescriptor>
|
||||
fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ClassConstructorDescriptor>
|
||||
fun getFunctionsNames(classDescriptor: DeserializedClassDescriptor): Collection<Name>
|
||||
|
||||
object None : AdditionalClassPartsProvider {
|
||||
override fun getSupertypes(classDescriptor: DeserializedClassDescriptor): Collection<KotlinType> = emptyList()
|
||||
override fun getFunctions(name: Name, classDescriptor: DeserializedClassDescriptor): Collection<SimpleFunctionDescriptor> = emptyList()
|
||||
override fun getFunctionsNames(classDescriptor: DeserializedClassDescriptor): Collection<Name> = emptyList()
|
||||
override fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ConstructorDescriptor> = emptyList()
|
||||
override fun getConstructors(classDescriptor: DeserializedClassDescriptor): Collection<ClassConstructorDescriptor> = emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -197,9 +197,9 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
return (c.containingDeclaration as? ClassDescriptor)?.thisAsReceiverParameter
|
||||
}
|
||||
|
||||
fun loadConstructor(proto: ProtoBuf.Constructor, isPrimary: Boolean): ConstructorDescriptor {
|
||||
fun loadConstructor(proto: ProtoBuf.Constructor, isPrimary: Boolean): ClassConstructorDescriptor {
|
||||
val classDescriptor = c.containingDeclaration as ClassDescriptor
|
||||
val descriptor = DeserializedConstructorDescriptor(
|
||||
val descriptor = DeserializedClassConstructorDescriptor(
|
||||
classDescriptor, null, getAnnotations(proto, proto.flags, AnnotatedCallableKind.FUNCTION),
|
||||
isPrimary, CallableMemberDescriptor.Kind.DECLARATION, proto, c.nameResolver, c.typeTable, c.containerSource
|
||||
)
|
||||
|
||||
+2
-2
@@ -106,8 +106,8 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
|
||||
|
||||
override fun getUnsubstitutedMemberScope() = MemberScope.Empty
|
||||
override fun getStaticScope() = MemberScope.Empty
|
||||
override fun getConstructors(): Collection<ConstructorDescriptor> = emptySet()
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = null
|
||||
override fun getConstructors(): Collection<ClassConstructorDescriptor> = emptySet()
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ClassConstructorDescriptor? = null
|
||||
override fun getCompanionObjectDescriptor(): ClassDescriptor? = null
|
||||
|
||||
override fun toString() = "class $name (not found)"
|
||||
|
||||
+4
-4
@@ -101,7 +101,7 @@ class DeserializedClassDescriptor(
|
||||
|
||||
override fun isCompanionObject(): Boolean = Flags.CLASS_KIND.get(classProto.flags) == ProtoBuf.Class.Kind.COMPANION_OBJECT
|
||||
|
||||
private fun computePrimaryConstructor(): ConstructorDescriptor? {
|
||||
private fun computePrimaryConstructor(): ClassConstructorDescriptor? {
|
||||
if (kind.isSingleton) {
|
||||
return DescriptorFactory.createPrimaryConstructorForObject(this, SourceElement.NO_SOURCE).apply {
|
||||
returnType = getDefaultType()
|
||||
@@ -113,13 +113,13 @@ class DeserializedClassDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ConstructorDescriptor? = primaryConstructor()
|
||||
override fun getUnsubstitutedPrimaryConstructor(): ClassConstructorDescriptor? = primaryConstructor()
|
||||
|
||||
private fun computeConstructors(): Collection<ConstructorDescriptor> =
|
||||
private fun computeConstructors(): Collection<ClassConstructorDescriptor> =
|
||||
computeSecondaryConstructors() + unsubstitutedPrimaryConstructor.singletonOrEmptyList() +
|
||||
c.components.additionalClassPartsProvider.getConstructors(this)
|
||||
|
||||
private fun computeSecondaryConstructors(): List<ConstructorDescriptor> =
|
||||
private fun computeSecondaryConstructors(): List<ClassConstructorDescriptor> =
|
||||
classProto.constructorList.filter { Flags.IS_SECONDARY.get(it.flags) }.map {
|
||||
c.memberDeserializer.loadConstructor(it, false)
|
||||
}
|
||||
|
||||
+4
-4
@@ -103,7 +103,7 @@ class DeserializedPropertyDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
class DeserializedConstructorDescriptor(
|
||||
class DeserializedClassConstructorDescriptor(
|
||||
containingDeclaration: ClassDescriptor,
|
||||
original: ConstructorDescriptor?,
|
||||
annotations: Annotations,
|
||||
@@ -115,7 +115,7 @@ class DeserializedConstructorDescriptor(
|
||||
override val containerSource: SourceElement?,
|
||||
source: SourceElement? = null
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
ConstructorDescriptorImpl(containingDeclaration, original, annotations, isPrimary, kind, source ?: SourceElement.NO_SOURCE) {
|
||||
ClassConstructorDescriptorImpl(containingDeclaration, original, annotations, isPrimary, kind, source ?: SourceElement.NO_SOURCE) {
|
||||
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
@@ -124,8 +124,8 @@ class DeserializedConstructorDescriptor(
|
||||
newName: Name?,
|
||||
annotations: Annotations,
|
||||
source: SourceElement
|
||||
): DeserializedConstructorDescriptor {
|
||||
return DeserializedConstructorDescriptor(
|
||||
): DeserializedClassConstructorDescriptor {
|
||||
return DeserializedClassConstructorDescriptor(
|
||||
newOwner as ClassDescriptor, original as ConstructorDescriptor?, annotations, isPrimary, kind,
|
||||
proto, nameResolver, typeTable, containerSource, source
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user