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)
}
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
mglukhikh
12/28/2023, 5:48 PM
I don't remember such an issue, so please report it.