Fix ComputedField being unable to properly handle nullable types
This commit is contained in:
parent
e5d324f4fa
commit
232701b8bb
@ -1012,8 +1012,8 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
private val codec: IStreamCodec<V>,
|
||||
private val observer: (new: V) -> Unit = {}
|
||||
) : AbstractField<V>(), IField<V> {
|
||||
private var remote: V? = null
|
||||
private var clientValue: V? = null
|
||||
private var remote: Any? = Mark
|
||||
private var clientValue: Any? = Mark
|
||||
|
||||
init {
|
||||
observers.add(this)
|
||||
@ -1024,7 +1024,7 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
|
||||
val value = value
|
||||
|
||||
if (!isDirty && (remote == null || !codec.compare(remote ?: throw ConcurrentModificationException(), value))) {
|
||||
if (!isDirty && (remote === Mark || !codec.compare(remote as V, value))) {
|
||||
notifyEndpoints(this)
|
||||
isDirty = true
|
||||
remote = codec.copy(value)
|
||||
@ -1034,7 +1034,15 @@ class FieldSynchronizer(private val callback: Runnable, private val alwaysCallCa
|
||||
}
|
||||
|
||||
override val value: V
|
||||
get() = clientValue ?: getter.invoke()
|
||||
get() {
|
||||
val clientValue = clientValue
|
||||
|
||||
if (clientValue === Mark) {
|
||||
return getter.invoke()
|
||||
} else {
|
||||
return clientValue as V
|
||||
}
|
||||
}
|
||||
|
||||
override fun write(stream: DataOutputStream, endpoint: Endpoint) {
|
||||
check(!isRemoved) { "Field was removed" }
|
||||
|
Loading…
Reference in New Issue
Block a user