Fix MessageChainBuilder.addAndCheckConstrainSingle

This commit is contained in:
Him188 2020-04-06 20:01:19 +08:00
parent 5c8e995d78
commit 7015f0f4e9

View File

@ -63,8 +63,13 @@ class MessageChainBuilder private constructor(
} }
val key = element.key val key = element.key
container[container.indexOfFirst(firstConstrainSingleIndex) { it is ConstrainSingle<*> && it.key == key }] = val index = container.indexOfFirst(firstConstrainSingleIndex) { it is ConstrainSingle<*> && it.key == key }
element if (index != -1) {
container[index] = element
} else {
add(element)
}
return true return true
} else { } else {
return container.add(element) return container.add(element)