From ca908ef4bd6fe04d8610ac1aefa1780fbf1ac19b Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Tue, 7 Feb 2017 17:02:07 +0300 Subject: [PATCH] Sort fields for RTTI, so that the order of fields in IR and the order of fields in the deserialized descriptors are the same. --- .../kotlin/backend/konan/llvm/LlvmDeclarations.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmDeclarations.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmDeclarations.kt index 08c7070c5f0..c5468b1a74a 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmDeclarations.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/LlvmDeclarations.kt @@ -99,10 +99,10 @@ private fun getDeclaredFields(context: Context, classDescriptor: ClassDescriptor // two ways: first we check IR, then we check the annotation. val irClass = context.ir.moduleIndexForCodegen.classes[classDescriptor] - if (irClass != null) { + val fields = if (irClass != null) { val declarations = irClass.declarations - return declarations.mapNotNull { + declarations.mapNotNull { when (it) { is IrProperty -> it.backingField?.descriptor is IrField -> it.descriptor @@ -114,7 +114,10 @@ private fun getDeclaredFields(context: Context, classDescriptor: ClassDescriptor getContributedDescriptors(). filterIsInstance() - return properties.mapNotNull { it.backingField } + properties.mapNotNull { it.backingField } + } + return fields.sortedBy { + it.name.hashCode() } }