From 0eb9007adddf53f335d48112e773e931f2417c0f Mon Sep 17 00:00:00 2001 From: Alexander Gorshenev Date: Wed, 8 Feb 2017 19:53:49 +0300 Subject: [PATCH] Use localHash instead of hashCode for field ordering. --- .../kotlin/backend/konan/llvm/LlvmDeclarations.kt | 13 +++++++------ 1 file changed, 7 insertions(+), 6 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 c5468b1a74a..6fe15b54f89 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 @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny +import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe internal fun createLlvmDeclarations(context: Context): LlvmDeclarations { val generator = DeclarationsGeneratorVisitor(context) @@ -72,17 +73,17 @@ internal class StaticFieldLlvmDeclarations(val storage: LLVMValueRef) * All fields of the class instance. * The order respects the class hierarchy, i.e. a class [fields] contains superclass [fields] as a prefix. */ -private fun getFields(context: Context, classDescriptor: ClassDescriptor): List { +internal fun ContextUtils.getFields(classDescriptor: ClassDescriptor): List { val superClass = classDescriptor.getSuperClassNotAny() // TODO: what if Any has fields? - val superFields = if (superClass != null) getFields(context, superClass) else emptyList() + val superFields = if (superClass != null) getFields(superClass) else emptyList() - return superFields + getDeclaredFields(context, classDescriptor) + return superFields + getDeclaredFields(classDescriptor) } /** * Fields declared in the class. */ -private fun getDeclaredFields(context: Context, classDescriptor: ClassDescriptor): List { +private fun ContextUtils.getDeclaredFields(classDescriptor: ClassDescriptor): List { // TODO: Here's what is going on here: // The existence of a backing field for a property is only described in the IR, // but not in the property descriptor. @@ -117,7 +118,7 @@ private fun getDeclaredFields(context: Context, classDescriptor: ClassDescriptor properties.mapNotNull { it.backingField } } return fields.sortedBy { - it.name.hashCode() + it.fqNameSafe.localHash.value } } @@ -212,7 +213,7 @@ private class DeclarationsGeneratorVisitor(override val context: Context) : val internalName = qualifyInternalName(descriptor) - val fields = getFields(context, descriptor) + val fields = getFields(descriptor) val bodyType = createClassBodyType("kclassbody:$internalName", fields) val typeInfoPtr: ConstPointer