Some more use of .propertyIfAccessor .

This commit is contained in:
Alexander Gorshenev
2017-04-25 18:05:02 +03:00
committed by alexander-gorshenev
parent 8a0b494c2e
commit 2ae88c9731
3 changed files with 14 additions and 14 deletions
@@ -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)
@@ -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"}
@@ -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))