Drop 'index' JVM binary format extension
Compute the JVM parameer index manually instead
This commit is contained in:
+6
-17
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.resolve.DescriptorFactory
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.*
|
||||
@@ -219,7 +218,11 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
val flags = if (proto.hasFlags()) proto.flags else 0
|
||||
ValueParameterDescriptorImpl(
|
||||
callableDescriptor, null, i,
|
||||
containerOfCallable?.let { getParameterAnnotations(it, callable, kind, i, proto) } ?: Annotations.EMPTY,
|
||||
containerOfCallable?.let { container ->
|
||||
DeserializedAnnotations(c.storageManager) {
|
||||
c.components.annotationAndConstantLoader.loadValueParameterAnnotations(container, callable, kind, i, proto)
|
||||
}
|
||||
} ?: Annotations.EMPTY,
|
||||
c.nameResolver.getName(proto.name),
|
||||
c.typeDeserializer.type(proto.type(c.typeTable)),
|
||||
Flags.DECLARES_DEFAULT_VALUE.get(flags),
|
||||
@@ -231,24 +234,10 @@ public class MemberDeserializer(private val c: DeserializationContext) {
|
||||
}.toReadOnlyList()
|
||||
}
|
||||
|
||||
private fun getParameterAnnotations(
|
||||
container: ProtoContainer,
|
||||
callable: MessageLite,
|
||||
kind: AnnotatedCallableKind,
|
||||
index: Int,
|
||||
valueParameter: ProtoBuf.ValueParameter
|
||||
): Annotations {
|
||||
return DeserializedAnnotations(c.storageManager) {
|
||||
c.components.annotationAndConstantLoader.loadValueParameterAnnotations(container, callable, kind, index, valueParameter)
|
||||
}
|
||||
}
|
||||
|
||||
private fun DeclarationDescriptor.asProtoContainer(): ProtoContainer? = when (this) {
|
||||
is PackageFragmentDescriptor -> ProtoContainer.Package(fqName, c.nameResolver, c.typeTable, c.packagePartSource)
|
||||
is DeserializedClassDescriptor -> ProtoContainer.Class(
|
||||
classProto, c.nameResolver, c.typeTable,
|
||||
isCompanionOfClass = DescriptorUtils.isCompanionObject(this) && DescriptorUtils.isClassOrEnumClass(containingDeclaration),
|
||||
isInterface = kind == ClassKind.INTERFACE
|
||||
classProto, c.nameResolver, c.typeTable, (containingDeclaration as? ClassDescriptor)?.kind
|
||||
)
|
||||
else -> null // TODO: support annotations on lambdas and their parameters
|
||||
}
|
||||
|
||||
+6
-2
@@ -16,8 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.serialization.Flags
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.PackagePartSource
|
||||
|
||||
@@ -29,11 +31,13 @@ sealed class ProtoContainer(
|
||||
val classProto: ProtoBuf.Class,
|
||||
nameResolver: NameResolver,
|
||||
typeTable: TypeTable,
|
||||
val isCompanionOfClass: Boolean,
|
||||
val isInterface: Boolean
|
||||
val outerClassKind: ClassKind?
|
||||
) : ProtoContainer(nameResolver, typeTable) {
|
||||
val classId: ClassId = nameResolver.getClassId(classProto.fqName)
|
||||
|
||||
val kind: ProtoBuf.Class.Kind = Flags.CLASS_KIND.get(classProto.flags) ?: ProtoBuf.Class.Kind.CLASS
|
||||
val isInner: Boolean = Flags.IS_INNER.get(classProto.flags)
|
||||
|
||||
override fun debugFqName(): FqName = classId.asSingleFqName()
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -288,19 +288,19 @@ public class DeserializedClassDescriptor(
|
||||
|
||||
private inner class EnumEntryClassDescriptors {
|
||||
private val enumEntryProtos = classProto.enumEntryList.toMapBy { c.nameResolver.getName(it.name) }
|
||||
private val protoContainer =
|
||||
ProtoContainer.Class(classProto, c.nameResolver, c.typeTable, (containingDeclaration as? ClassDescriptor)?.kind)
|
||||
|
||||
val enumEntryByName = c.storageManager.createMemoizedFunctionWithNullableValues<Name, ClassDescriptor> {
|
||||
name ->
|
||||
|
||||
enumEntryProtos[name]?.let { proto ->
|
||||
val annotations = DeserializedAnnotations(c.storageManager) {
|
||||
c.components.annotationAndConstantLoader.loadEnumEntryAnnotations(
|
||||
ProtoContainer.Class(classProto, c.nameResolver, c.typeTable, isCompanionOfClass = false, isInterface = false),
|
||||
proto
|
||||
)
|
||||
}
|
||||
EnumEntrySyntheticClassDescriptor.create(
|
||||
c.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames, annotations, SourceElement.NO_SOURCE
|
||||
c.storageManager, this@DeserializedClassDescriptor, name, enumMemberNames,
|
||||
DeserializedAnnotations(c.storageManager) {
|
||||
c.components.annotationAndConstantLoader.loadEnumEntryAnnotations(protoContainer, proto)
|
||||
},
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user