From 2ae88c97312d1fdb58d34bfbbe6cb7c6a8fc8486 Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 25 Apr 2017 18:05:02 +0300 Subject: [PATCH] Some more use of .propertyIfAccessor . --- .../kotlin/backend/konan/descriptors/utils.kt | 7 ++++++- .../serialization/IrDescriptorSerializer.kt | 20 +++++++------------ .../serialization/KonanSerializationUtil.kt | 1 + 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/utils.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/utils.kt index 9cb48f2e609..5b6215d1895 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/utils.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/utils.kt @@ -65,6 +65,11 @@ internal val DeclarationDescriptor.propertyIfAccessor this.correspondingProperty else this +internal val CallableMemberDescriptor.propertyIfAccessor + get() = if (this is PropertyAccessorDescriptor) + this.correspondingProperty + else this + internal val FunctionDescriptor.deserializedPropertyIfAccessor: DeserializedCallableMemberDescriptor get() { val member = this.propertyIfAccessor @@ -74,7 +79,7 @@ internal val FunctionDescriptor.deserializedPropertyIfAccessor: DeserializedCall error("Unexpected deserializable callable descriptor") } -internal val DeclarationDescriptor.isDeserializableCallable +internal val CallableMemberDescriptor.isDeserializableCallable get () = (this.propertyIfAccessor is DeserializedCallableMemberDescriptor) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/IrDescriptorSerializer.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/IrDescriptorSerializer.kt index 24b5c68dad8..d3ec0a6b47f 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/IrDescriptorSerializer.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/IrDescriptorSerializer.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.backend.konan.serialization import org.jetbrains.kotlin.backend.konan.Context +import org.jetbrains.kotlin.backend.konan.descriptors.* import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor import org.jetbrains.kotlin.ir.descriptors.IrTemporaryVariableDescriptor @@ -80,18 +81,15 @@ internal class IrDescriptorSerializer( fun functionDescriptorSpecifics(descriptor: FunctionDescriptor, proto: KonanIr.KotlinDescriptor.Builder) { - descriptor.valueParameters.forEach { - proto.addValueParameter(serializeDescriptor(it)) - } - - val typeParameters = if (descriptor is PropertyAccessorDescriptor) - descriptor.correspondingProperty.typeParameters - else descriptor.typeParameters - + val typeParameters = descriptor.propertyIfAccessor.typeParameters typeParameters.forEach { proto.addTypeParameter(serializeDescriptor(it)) } + descriptor.valueParameters.forEach { + proto.addValueParameter(serializeDescriptor(it)) + } + // Allocate two indicies for the receivers. // They are not deserialized from protobuf, // just recreated together with their function. @@ -135,11 +133,7 @@ internal class IrDescriptorSerializer( val index = descriptorTable.indexByValue(descriptor) // For getters and setters we use // the *property* original index. - val originalIndex = if (descriptor is PropertyAccessorDescriptor) { - descriptorTable.indexByValue(descriptor.correspondingProperty.original) - } else { - descriptorTable.indexByValue(descriptor.original) - } + val originalIndex = descriptorTable.indexByValue(descriptor.propertyIfAccessor.original) context.log{"index = $index"} context.log{"originalIndex = $originalIndex"} diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanSerializationUtil.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanSerializationUtil.kt index 0d60c14eb5c..c21f6db2631 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanSerializationUtil.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanSerializationUtil.kt @@ -304,6 +304,7 @@ internal class KonanSerializationUtil(val context: Context) { when (descriptor) { is FunctionDescriptor -> proto.setFunction(serializer.functionProto(descriptor)) + is PropertyDescriptor -> proto.setProperty(serializer.propertyProto(descriptor))