(Fixed check :thread:) Good Timezone to everyone. ...
# kotlin-native
m
(Fixed check 🧵) Good Timezone to everyone. I’m facing a weird issue with the following code:
Copy code
override suspend fun ArcherRaise.invoke(q: KeyQuery<K, out A>): A & Any =
            println(q)
            println(this)
            println(this@invoke)
            when (q) {
                is Put -> {
                    q.value?.also { values[q.key] = it } ?: raise(DataNotFound)
                }

                is Get -> {
                    values[q.key] ?: raise(DataNotFound)
                }
            }
ArcherRaise
is a custom object that I use for scoping the invoke function of my class. The issue is that when I’m running the code
println(q)
prints
ArcherRaise(raise=0)
where q is a totally different type, a
KeyQuery
. This is causing a runtime exception:
kotlin.NoWhenBranchMatchedException
note: on JVM this works as expected
the when expression expects KeyQuery that is a sealed definition for Get or Put only. the exception makes sense as Q looksbeing a totally different object but I can’t understand why the compiler (?) thinks in another object
for those interested I already fixed the issue: ArcherRaise as a
@JvmInline
class making the compiler get crazy and replace some parameters./