[FE, IR] Support deserialization
This commit is contained in:
committed by
TeamCityServer
parent
2fbfee3e11
commit
617af898b0
+12
-2
@@ -60,7 +60,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
proto.receiverType(c.typeTable)?.let(local.typeDeserializer::type)?.let { receiverType ->
|
||||
DescriptorFactory.createExtensionReceiverParameterForCallable(property, receiverType, receiverAnnotations)
|
||||
},
|
||||
emptyList()
|
||||
proto.contextReceiverTypeList.map { it.toContextReceiver(local, property) }
|
||||
)
|
||||
|
||||
// Per documentation on Property.getter_flags in metadata.proto, if an accessor flags field is absent, its value should be computed
|
||||
@@ -152,6 +152,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
private fun DeserializedSimpleFunctionDescriptor.initializeWithCoroutinesExperimentalityStatus(
|
||||
extensionReceiverParameter: ReceiverParameterDescriptor?,
|
||||
dispatchReceiverParameter: ReceiverParameterDescriptor?,
|
||||
contextReceiverParameters: List<ReceiverParameterDescriptor>,
|
||||
typeParameters: List<TypeParameterDescriptor>,
|
||||
unsubstitutedValueParameters: List<ValueParameterDescriptor>,
|
||||
unsubstitutedReturnType: KotlinType?,
|
||||
@@ -162,7 +163,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
initialize(
|
||||
extensionReceiverParameter,
|
||||
dispatchReceiverParameter,
|
||||
emptyList(), // TODO
|
||||
contextReceiverParameters,
|
||||
typeParameters,
|
||||
unsubstitutedValueParameters,
|
||||
unsubstitutedReturnType,
|
||||
@@ -202,6 +203,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
DescriptorFactory.createExtensionReceiverParameterForCallable(function, receiverType, receiverAnnotations)
|
||||
},
|
||||
getDispatchReceiverParameter(),
|
||||
proto.contextReceiverTypeList.mapNotNull { it.toContextReceiver(local, function) },
|
||||
local.typeDeserializer.ownTypeParameters,
|
||||
local.memberDeserializer.valueParameters(proto.valueParameterList, proto, AnnotatedCallableKind.FUNCTION),
|
||||
local.typeDeserializer.type(proto.returnType(c.typeTable)),
|
||||
@@ -341,4 +343,12 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
is DeserializedClassDescriptor -> thisAsProtoContainer
|
||||
else -> null // TODO: support annotations on lambdas and their parameters
|
||||
}
|
||||
|
||||
private fun ProtoBuf.Type.toContextReceiver(
|
||||
deserializationContext: DeserializationContext,
|
||||
callableDescriptor: CallableDescriptor
|
||||
): ReceiverParameterDescriptor? {
|
||||
val contextReceiverType = deserializationContext.typeDeserializer.type(this)
|
||||
return DescriptorFactory.createContextReceiverParameterForCallable(callableDescriptor, contextReceiverType, Annotations.EMPTY)
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.AbstractClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.EnumEntrySyntheticClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.ReceiverParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.incremental.record
|
||||
@@ -20,6 +21,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.StaticScopeForKotlinEnum
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ContextClassReceiver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.*
|
||||
import org.jetbrains.kotlin.types.AbstractClassTypeConstructor
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
@@ -140,6 +142,15 @@ class DeserializedClassDescriptor(
|
||||
|
||||
override fun getConstructors() = constructors()
|
||||
|
||||
override fun getContextReceivers(): List<ReceiverParameterDescriptor> = classProto.contextReceiverTypeList.map {
|
||||
val contextReceiverType = c.typeDeserializer.type(it)
|
||||
ReceiverParameterDescriptorImpl(
|
||||
thisAsReceiverParameter,
|
||||
ContextClassReceiver(this, contextReceiverType, null),
|
||||
Annotations.EMPTY
|
||||
);
|
||||
}
|
||||
|
||||
private fun computeCompanionObjectDescriptor(): ClassDescriptor? {
|
||||
if (!classProto.hasCompanionObjectName()) return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user