``` fun main() { val x = Thing(42) when(x)...
# announcements
l
Copy code
fun main() {
    val x = Thing(42)
    when(x) {
        Thing(42) -> {
            println("foo")
        }
        else -> {
            println("bar")
        }
    }
}

inline class Thing(val value: Int)
the output is
foo
IntelliJ suggests inlining
x
, like so:
Copy code
fun main() {
    when(val x = Thing(42)) {
        Thing(42) -> {
            println("foo")
        }
        else -> {
            println("bar")
        }
    }
}

inline class Thing(val value: Int)
however now it outputs
bar
. why is that?
k
That has to be a compiler bug I think, report on youtrack.
e
Can you check decompiled code?
I wonder if it is int or Integer after inlining
👆 1
w
Can you declare type for the inlined
val
? Would
val x: Thing = Thing(42)
work as expected?
s
For some reason, it looks like one example is auto-boxed into a 'Thing' and the other example remains inlined, like an 'Int'. No idea why.... Looks like a bug... or at least super confusing...