Introduce conversions from signed pure constants to unsigned ones
#KT-24717 In Progress #KT-25996 Open #KT-25997 Open
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
// WITH_UNSIGNED
|
||||
// IGNORE_BACKEND: JS_IR, JVM_IR, JS
|
||||
|
||||
fun takeUByte(u: UByte) = u.toByte()
|
||||
fun takeUShort(u: UShort) = u.toShort()
|
||||
fun takeUInt(u: UInt) = u.toInt()
|
||||
fun takeULong(u: ULong) = u.toLong()
|
||||
|
||||
fun box(): String {
|
||||
val b = takeUByte(200 + 55)
|
||||
if (b != (-1).toByte()) return "Fail 1: $b"
|
||||
|
||||
val s = takeUShort(123)
|
||||
if (s != 123.toShort()) return "Fail 2: $s"
|
||||
|
||||
val i = takeUInt(0xFFFF_FFFF)
|
||||
if (i != -1) return "Fail 3: $i"
|
||||
|
||||
val l = takeULong(0xFFFF_FFFF_FFFF)
|
||||
if (l != 0xFFFF_FFFF_FFFFL) return "Fail 4: $l"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user