Fix for value equality in JS

This commit is contained in:
Alexander Nozik 2019-08-10 17:28:27 +03:00
parent 56679cff23
commit d1061a6669
2 changed files with 9 additions and 7 deletions

View File

@ -133,12 +133,12 @@ class NumberValue(override val number: Number) : Value {
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (other !is Value) return false if (other !is Value) return false
return when (number) { return when (number) {
is Short -> number == other.number.toShort() is Short -> number.toShort() == other.number.toShort()
is Long -> number == other.number.toLong() is Long -> number.toLong() == other.number.toLong()
is Byte -> number == other.number.toByte() is Byte -> number.toByte() == other.number.toByte()
is Int -> number == other.number.toInt() is Int -> number.toInt() == other.number.toInt()
is Float -> number == other.number.toFloat() is Float -> number.toFloat() == other.number.toFloat()
is Double -> number == other.number.toDouble() is Double -> number.toDouble() == other.number.toDouble()
else -> number.toString() == other.number.toString() else -> number.toString() == other.number.toString()
} }
} }

View File

@ -27,7 +27,8 @@ class HtmlOutput<T : Any>(override val context: Context, private val consumer: T
} else { } else {
val value = cache[obj::class] val value = cache[obj::class]
if (value == null) { if (value == null) {
val answer = context.top<HtmlBuilder<*>>(HTML_CONVERTER_TYPE).values.firstOrNull { it.type.isInstance(obj) } val answer =
context.top<HtmlBuilder<*>>(HTML_CONVERTER_TYPE).values.firstOrNull { it.type.isInstance(obj) }
if (answer != null) { if (answer != null) {
cache[obj::class] = answer cache[obj::class] = answer
answer answer
@ -39,6 +40,7 @@ class HtmlOutput<T : Any>(override val context: Context, private val consumer: T
} }
} }
context.launch(Dispatchers.Output) { context.launch(Dispatchers.Output) {
@Suppress("UNCHECKED_CAST")
(builder as HtmlBuilder<T>).run { consumer.render(obj) } (builder as HtmlBuilder<T>).run { consumer.render(obj) }
} }
} }