Kotlin / kotlin-interactive-shell

Kotlin Language Interactive Shell
Apache License 2.0
587 stars 36 forks source link

Explicit cast (1L as ULong) is not allowed #114

Closed sten1ee closed 2 years ago

sten1ee commented 2 years ago

Evaluating the following code in ki-shell 0.5.1/1.7.0:

1L as ULong

Results in:

java.lang.ClassCastException: class java.lang.Long cannot be cast to class kotlin.ULong (java.lang.Long is in module java.base of loader 'bootstrap'; kotlin.ULong is in unnamed module of loader 'app')
    at Line_34.<init>(Line_34.kts:1)

The other way around (explicitly casting ULong to Long) fails in a similar way. (I am aware that this may be language 'feature' not a bug)

asm0dey commented 2 years ago

But the correct way to do it is 1L.toULong()!