I think I've found a compiler bug wrt inline class...
# announcements
r
I think I've found a compiler bug wrt inline classes, could someone confirm that my suspicion is correct? I'm trying to convert an existing units library that I use to use inline classes rather than boxing every entity. Once I'd completed, some of the tests for this project were failing with ClassCastException errors. I looked into it with a decompiler, and found that in one of the cases where I'd used the inline class, the decompiler shows a cast to Double from Length, and I assume that's what's causing the exception.

https://0x0.st/zj-H.png

The source version of that is this:
operator fun contains(p: Translation2d) = p.x in x..(x + w) && p.y in y..(y + h)
where all of the fields in use are Length, the inline class wrapping Double
k
I ran into the same issue with http://units.kunalsheth.info. What kotlin version are you using?
s
subtle
k
I saw that a lot in the 1.3 Release Candidates. Eventually I gave up and explicitly boxed wherever the exceptions were thrown:
fun <Q : Quan<Q>> box(x: Q) = x as Quan<Q>
This is the issue I had: https://youtrack.jetbrains.com/issue/KT-29075 but there are plenty more ClassCastExceptions with inline classes: https://youtrack.jetbrains.com/issues/KT?q=inline%20class%20ClassCastException
r
I'm using 1.3.30
i
@redrield Could you file an issue with the code to reproduce it?