Sort fields for RTTI, so that the order of fields in IR and the order of fields in

the deserialized descriptors are the same.
This commit is contained in:
Alexander Gorshenev
2017-02-07 17:02:07 +03:00
committed by alexander-gorshenev
parent 4b27074979
commit ca908ef4bd
@@ -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<PropertyDescriptor>()
return properties.mapNotNull { it.backingField }
properties.mapNotNull { it.backingField }
}
return fields.sortedBy {
it.name.hashCode()
}
}