https://kotlinlang.org logo
#announcements
Title
# announcements
r

redrield

06/14/2019, 8:02 PM
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

kunalsheth

06/14/2019, 8:35 PM
I ran into the same issue with http://units.kunalsheth.info. What kotlin version are you using?
s

Shawn

06/14/2019, 8:39 PM
subtle
k

kunalsheth

06/14/2019, 8:52 PM
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

redrield

06/14/2019, 9:07 PM
I'm using 1.3.30
i

ilya.gorbunov

06/16/2019, 1:42 AM
@redrield Could you file an issue with the code to reproduce it?