diff --git a/serialization/src/main/kotlin/net/corda/serialization/internal/model/LocalTypeInformationBuilder.kt b/serialization/src/main/kotlin/net/corda/serialization/internal/model/LocalTypeInformationBuilder.kt index adf3a7dd35..124a5a1847 100644 --- a/serialization/src/main/kotlin/net/corda/serialization/internal/model/LocalTypeInformationBuilder.kt +++ b/serialization/src/main/kotlin/net/corda/serialization/internal/model/LocalTypeInformationBuilder.kt @@ -299,19 +299,23 @@ internal data class LocalTypeInformationBuilder(val lookup: LocalTypeLookup, }.toMap() return rawType.propertyDescriptors().asSequence().mapNotNull { (name, descriptor) -> - val property = makeConstructorPairedProperty(constructorParameterIndices, name, descriptor, constructorInformation) - if (property == null) null else name to property + val normalisedName = when { + name in constructorParameterIndices -> name + name.decapitalize() in constructorParameterIndices -> name.decapitalize() + else -> return@mapNotNull null + } + + val property = makeConstructorPairedProperty( + constructorParameterIndices[normalisedName]!!, + descriptor, + constructorInformation) + if (property == null) null else normalisedName to property } } - private fun makeConstructorPairedProperty(constructorParameterIndices: Map, - name: String, + private fun makeConstructorPairedProperty(constructorIndex: Int, descriptor: PropertyDescriptor, constructorInformation: LocalConstructorInformation): LocalPropertyInformation? { - // In some very rare cases we have a constructor parameter matched by a getter with no backing field, - // and cannot infer whether the property name should be capitalised or not. - val constructorIndex = constructorParameterIndices[name] ?: constructorParameterIndices[name.decapitalize()] - if (constructorIndex == null) return null if (descriptor.getter == null) { if (descriptor.field == null) return null