Fix metadata deserialization for context receivers with type table

In DeserializedClassDescriptor and MemberDeserializer, only the
`contextReceiverTypeList` field was used, and not
`contextReceiverTypeIdList` which is used when `-Xuse-type-table` is
enabled. The convention is to use a bunch of utilities declared in
`protoTypeTableUtil.kt` which deal with both methods of reading types.
Also, simplify the deserialization code in FIR (which was correct for
some reason).
This commit is contained in:
Alexander Udalov
2022-06-14 00:16:59 +02:00
parent 71f6c0b1b2
commit 08f18c2940
13 changed files with 178 additions and 38 deletions
@@ -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)
},
proto.contextReceiverTypeList.map { it.toContextReceiver(local, property) }
proto.contextReceiverTypes(c.typeTable).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
@@ -212,7 +212,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
DescriptorFactory.createExtensionReceiverParameterForCallable(function, receiverType, receiverAnnotations)
},
getDispatchReceiverParameter(),
proto.contextReceiverTypeList.mapNotNull { it.toContextReceiver(local, function) },
proto.contextReceiverTypes(c.typeTable).mapNotNull { it.toContextReceiver(local, function) },
local.typeDeserializer.ownTypeParameters,
local.memberDeserializer.valueParameters(proto.valueParameterList, proto, AnnotatedCallableKind.FUNCTION),
local.typeDeserializer.type(proto.returnType(c.typeTable)),
@@ -146,7 +146,7 @@ class DeserializedClassDescriptor(
override fun getConstructors() = constructors()
override fun getContextReceivers(): List<ReceiverParameterDescriptor> = classProto.contextReceiverTypeList.map {
override fun getContextReceivers(): List<ReceiverParameterDescriptor> = classProto.contextReceiverTypes(c.typeTable).map {
val contextReceiverType = c.typeDeserializer.type(it)
ReceiverParameterDescriptorImpl(
thisAsReceiverParameter,