Hey there! I think I found a bug in K2 and/or JVM ...
# k2-adopters
m
Hey there! I think I found a bug in K2 and/or JVM backend. The following code runs fine on K1 (e.g. using Kotlin 1.9.21), but fails with a
ClassCastException
when run with 2.0.0-Beta2:
Copy code
val Number.lightyears get() = Lightyears(this.toDouble())
val UInt.lightyears get() = Lightyears(this.toDouble())

data class Lightyears(val years: Double)

fun main() {
    println(2.lightyears)
    println(2U.lightyears)
}
Kotlin Playground: https://pl.kotl.in/0zkCeRL8P This fails with:
Copy code
Exception in thread "main" java.lang.ClassCastException: class kotlin.UInt cannot be cast to class java.lang.Number (kotlin.UInt is in unnamed module of loader 'app'; java.lang.Number is in module java.base of loader 'bootstrap')
Is this issue already known?
🙏 1
m
I don't remember such an issue, so please report it.
👍 1