Kotlin / kotlin-interactive-shell

Kotlin Language Interactive Shell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Explicit cast (1L as ULong) is not allowed

sten1ee opened this issue · comments

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)

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