From 7307ffb3226c9f5446fe1dd1444baa2405f47866 Mon Sep 17 00:00:00 2001
From: Andrew Golovashevich <landgrafhomyak@gmail.com>
Date: Sun, 10 Nov 2024 18:57:14 +0300
Subject: [PATCH] Symbol names for future binary compatibility

---
 .../int_conversions_sign.kt                   |  37 +++-
 .../int_conversions_size.kt                   | 172 +++++++++++-------
 2 files changed, 146 insertions(+), 63 deletions(-)
 rename src/commonMain/kotlin/ru/landrafhomyak/kotlin/{multiplatform_switches => utilities}/int_conversions_sign.kt (92%)
 rename src/commonMain/kotlin/ru/landrafhomyak/kotlin/{multiplatform_switches => utilities}/int_conversions_size.kt (60%)

diff --git a/src/commonMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/int_conversions_sign.kt b/src/commonMain/kotlin/ru/landrafhomyak/kotlin/utilities/int_conversions_sign.kt
similarity index 92%
rename from src/commonMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/int_conversions_sign.kt
rename to src/commonMain/kotlin/ru/landrafhomyak/kotlin/utilities/int_conversions_sign.kt
index f80c4cb..0e64258 100644
--- a/src/commonMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/int_conversions_sign.kt
+++ b/src/commonMain/kotlin/ru/landrafhomyak/kotlin/utilities/int_conversions_sign.kt
@@ -1,7 +1,7 @@
 @file:JvmName("IntConversions_Sign")
 @file:Suppress("NOTHING_TO_INLINE")
 
-package ru.landrafhomyak.kotlin.multiplatform_switches
+package ru.landrafhomyak.kotlin.utilities
 
 import kotlin.contracts.InvocationKind
 import kotlin.contracts.contract
@@ -18,6 +18,7 @@ import kotlin.jvm.JvmName
  *
  * The resulting `UByte` value has the same binary representation as this `Byte` value.
  */
+@JvmName("asUByte")
 public inline fun Byte.asUByte(): UByte = this.toUByte()
 
 
@@ -29,6 +30,7 @@ public inline fun Byte.asUByte(): UByte = this.toUByte()
  *
  * The resulting `Byte` value has the same binary representation as this `UByte` value.
  */
+@JvmName("asByte")
 public inline fun UByte.asByte(): Byte = this.toByte()
 
 /**
@@ -38,6 +40,7 @@ public inline fun UByte.asByte(): Byte = this.toByte()
  *
  * The resulting `UShort` value has the same binary representation as this `Short` value.
  */
+@JvmName("asUShort")
 public inline fun Short.asUShort(): UShort = this.toUShort()
 
 
@@ -49,6 +52,7 @@ public inline fun Short.asUShort(): UShort = this.toUShort()
  *
  * The resulting `Short` value has the same binary representation as this `UShort` value.
  */
+@JvmName("asShort")
 public inline fun UShort.asShort(): Short = this.toShort()
 
 /**
@@ -58,6 +62,7 @@ public inline fun UShort.asShort(): Short = this.toShort()
  *
  * The resulting `UInt` value has the same binary representation as this `Int` value.
  */
+@JvmName("asUInt")
 public inline fun Int.asUInt(): UInt = this.toUInt()
 
 /**
@@ -68,6 +73,7 @@ public inline fun Int.asUInt(): UInt = this.toUInt()
  *
  * The resulting `Int` value has the same binary representation as this `UInt` value.
  */
+@JvmName("asInt")
 public inline fun UInt.asInt(): Int = this.toInt()
 
 
@@ -78,6 +84,7 @@ public inline fun UInt.asInt(): Int = this.toInt()
  *
  * The resulting `ULong` value has the same binary representation as this `Long` value.
  */
+@JvmName("asULong")
 public inline fun Long.asULong(): ULong = this.toULong()
 
 /**
@@ -88,6 +95,7 @@ public inline fun Long.asULong(): ULong = this.toULong()
  *
  * The resulting `Long` value has the same binary representation as this `ULong` value.
  */
+@JvmName("asLong")
 public inline fun ULong.asLong(): Long = this.toLong()
 
 
@@ -101,6 +109,7 @@ public inline fun ULong.asLong(): Long = this.toLong()
  * Otherwise `null` returned.
  */
 
+@JvmName("toUByteOrNull")
 public inline fun Byte.toUByteOrNull(): UByte? = if (this < 0) null else this.asUByte()
 
 
@@ -111,6 +120,7 @@ public inline fun Byte.toUByteOrNull(): UByte? = if (this < 0) null else this.as
  * the same numerical value as this [UByte].
  * Otherwise `null` returned.
  */
+@JvmName("toByteOrNull")
 public inline fun UByte.toByteOrNull(): Byte? = if (this >= Byte.MAX_VALUE.asUByte()) null else this.asByte()
 
 /**
@@ -119,6 +129,7 @@ public inline fun UByte.toByteOrNull(): Byte? = if (this >= Byte.MAX_VALUE.asUBy
  * If this value is positive, the resulting [UShort] value represents the same numerical value as this [Short].
  * Otherwise `null` returned.
  */
+@JvmName("toUShortOrNull")
 public inline fun Short.toUShortOrNull(): UShort? = if (this < 0) null else this.asUShort()
 
 
@@ -129,6 +140,7 @@ public inline fun Short.toUShortOrNull(): UShort? = if (this < 0) null else this
  * the same numerical value as this [UShort].
  * Otherwise `null` returned.
  */
+@JvmName("toShortOrNull")
 public inline fun UShort.toShortOrNull(): Short? = if (this >= Short.MAX_VALUE.asUShort()) null else this.asShort()
 
 /**
@@ -137,6 +149,7 @@ public inline fun UShort.toShortOrNull(): Short? = if (this >= Short.MAX_VALUE.a
  * If this value is positive, the resulting [UInt] value represents the same numerical value as this [Int].
  * Otherwise `null` returned.
  */
+@JvmName("toUIntOrNull")
 public inline fun Int.toUIntOrNull(): UInt? = if (this < 0) null else this.asUInt()
 
 /**
@@ -146,6 +159,7 @@ public inline fun Int.toUIntOrNull(): UInt? = if (this < 0) null else this.asUIn
  * the same numerical value as this [UInt].
  * Otherwise `null` returned.
  */
+@JvmName("toIntOrNull")
 public inline fun UInt.toIntOrNull(): Int? = if (this >= Int.MAX_VALUE.asUInt()) null else this.asInt()
 
 
@@ -155,6 +169,7 @@ public inline fun UInt.toIntOrNull(): Int? = if (this >= Int.MAX_VALUE.asUInt())
  * If this value is positive, the resulting [ULong] value represents the same numerical value as this [Long].
  * Otherwise `null` returned.
  */
+@JvmName("toULongOrNull")
 public inline fun Long.toULongOrNull(): ULong? = if (this < 0) null else this.asULong()
 
 /**
@@ -164,34 +179,45 @@ public inline fun Long.toULongOrNull(): ULong? = if (this < 0) null else this.as
  * the same numerical value as this [ULong].
  * Otherwise `null` returned.
  */
+@JvmName("toLongOrNull")
 public inline fun ULong.toLongOrNull(): Long? = if (this >= Long.MAX_VALUE.asULong()) null else this.asLong()
 
 
 /********************************************* Conversion error formatters ****************************************/
 
 @Suppress("FunctionName")
+@JvmName("_formatUnsignedToSignedOverflow")
 private inline fun <reified S, reified U> _formatUnsignedToSignedOverflow(value: U, limit: S) =
 	"Can't convert ${U::class.simpleName!!} value to ${S::class.simpleName!!} because $value > $limit"
 
 @Suppress("FunctionName")
+@JvmName("_formatSignedToUnsignedNegative")
 private inline fun <reified S, reified U> _formatSignedToUnsignedNegative(value: S) =
 	"Can't convert ${S::class.simpleName!!} value to ${U::class.simpleName!!} because $value is negative"
 
 
+@JvmName("formatToUByteError")
 public fun Byte.formatToUByteError(): String = _formatSignedToUnsignedNegative<Byte, UByte>(this)
 
+@JvmName("formatToByteError")
 public fun UByte.formatToByteError(): String = _formatUnsignedToSignedOverflow<Byte, UByte>(this, Byte.MAX_VALUE)
 
+@JvmName("formatToUShortError")
 public fun Short.formatToUShortError(): String = _formatSignedToUnsignedNegative<Short, UShort>(this)
 
+@JvmName("formatToShortError")
 public fun UShort.formatToShortError(): String = _formatUnsignedToSignedOverflow<Short, UShort>(this, Short.MAX_VALUE)
 
+@JvmName("formatToUIntError")
 public fun Int.formatToUIntError(): String = _formatSignedToUnsignedNegative<Int, UInt>(this)
 
+@JvmName("formatToIntError")
 public fun UInt.formatToIntError(): String = _formatUnsignedToSignedOverflow<Int, UInt>(this, Int.MAX_VALUE)
 
+@JvmName("formatToULongError")
 public fun Long.formatToULongError(): String = _formatSignedToUnsignedNegative<Long, ULong>(this)
 
+@JvmName("formatToLongError")
 public fun ULong.formatToLongError(): String = _formatUnsignedToSignedOverflow<Long, ULong>(this, Long.MAX_VALUE)
 
 
@@ -203,7 +229,7 @@ public fun ULong.formatToLongError(): String = _formatUnsignedToSignedOverflow<L
  * If this value is positive, the resulting [UByte] value represents the same numerical value as this [Byte].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-
+@JvmName("toUByteOrThrow")
 public inline fun Byte.toUByteOrThrow(exception: (Byte) -> Nothing = { b -> throw IllegalArgumentException(b.formatToUByteError()) }): UByte {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
@@ -220,6 +246,7 @@ public inline fun Byte.toUByteOrThrow(exception: (Byte) -> Nothing = { b -> thro
  * the same numerical value as this [UByte].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
+@JvmName("toByteOrThrow")
 public inline fun UByte.toByteOrThrow(exception: (UByte) -> Nothing = { b -> throw IllegalArgumentException(b.formatToByteError()) }): Byte {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
@@ -234,6 +261,7 @@ public inline fun UByte.toByteOrThrow(exception: (UByte) -> Nothing = { b -> thr
  * If this value is positive, the resulting [UShort] value represents the same numerical value as this [Short].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
+@JvmName("toUShortOrThrow")
 public inline fun Short.toUShortOrThrow(exception: (Short) -> Nothing = { b -> throw IllegalArgumentException(b.formatToUShortError()) }): UShort {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
@@ -250,6 +278,7 @@ public inline fun Short.toUShortOrThrow(exception: (Short) -> Nothing = { b -> t
  * the same numerical value as this [UShort].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
+@JvmName("toShortOrThrow")
 public inline fun UShort.toShortOrThrow(exception: (UShort) -> Nothing = { b -> throw IllegalArgumentException(b.formatToShortError()) }): Short {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
@@ -264,6 +293,7 @@ public inline fun UShort.toShortOrThrow(exception: (UShort) -> Nothing = { b ->
  * If this value is positive, the resulting [UInt] value represents the same numerical value as this [Int].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
+@JvmName("toUIntOrThrow")
 public inline fun Int.toUIntOrThrow(exception: (Int) -> Nothing = { b -> throw IllegalArgumentException(b.formatToUIntError()) }): UInt {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
@@ -279,6 +309,7 @@ public inline fun Int.toUIntOrThrow(exception: (Int) -> Nothing = { b -> throw I
  * the same numerical value as this [UInt].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
+@JvmName("toIntOrThrow")
 public inline fun UInt.toIntOrThrow(exception: (UInt) -> Nothing = { b -> throw IllegalArgumentException(b.formatToIntError()) }): Int {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
@@ -294,6 +325,7 @@ public inline fun UInt.toIntOrThrow(exception: (UInt) -> Nothing = { b -> throw
  * If this value is positive, the resulting [ULong] value represents the same numerical value as this [Long].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
+@JvmName("toULongOrThrow")
 public inline fun Long.toULongOrThrow(exception: (Long) -> Nothing = { b -> throw IllegalArgumentException(b.formatToULongError()) }): ULong {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
@@ -310,6 +342,7 @@ public inline fun Long.toULongOrThrow(exception: (Long) -> Nothing = { b -> thro
  * the same numerical value as this [ULong].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
+@JvmName("toLongOrThrow")
 public inline fun ULong.toLongOrThrow(exception: (ULong) -> Nothing = { b -> throw IllegalArgumentException(b.formatToLongError()) }): Long {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
diff --git a/src/commonMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/int_conversions_size.kt b/src/commonMain/kotlin/ru/landrafhomyak/kotlin/utilities/int_conversions_size.kt
similarity index 60%
rename from src/commonMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/int_conversions_size.kt
rename to src/commonMain/kotlin/ru/landrafhomyak/kotlin/utilities/int_conversions_size.kt
index 371c4fd..7be88dd 100644
--- a/src/commonMain/kotlin/ru/landrafhomyak/kotlin/multiplatform_switches/int_conversions_size.kt
+++ b/src/commonMain/kotlin/ru/landrafhomyak/kotlin/utilities/int_conversions_size.kt
@@ -1,7 +1,7 @@
 @file:JvmName("IntConversions_Size")
 @file:Suppress("NOTHING_TO_INLINE")
 
-package ru.landrafhomyak.kotlin.multiplatform_switches
+package ru.landrafhomyak.kotlin.utilities
 
 import kotlin.contracts.InvocationKind
 import kotlin.contracts.contract
@@ -15,84 +15,96 @@ import kotlin.jvm.JvmName
  *
  * The resulting [Short] value represents the same numerical value as this [Byte].
  */
-public inline fun Byte.asShort(): Short = this.toShort()
+@JvmName("extendToShort")
+public inline fun Byte.extendToShort(): Short = this.toShort()
 
 /**
  * Converts this [Byte] value to [Int].
  *
  * The resulting [Int] value represents the same numerical value as this [Byte].
  */
-public inline fun Byte.asInt(): Int = this.toInt()
+@JvmName("extendToInt")
+public inline fun Byte.extendToInt(): Int = this.toInt()
 
 /**
  * Converts this [Byte] value to [Long].
  *
  * The resulting [Long] value represents the same numerical value as this [Byte].
  */
-public inline fun Byte.asLong(): Long = this.toLong()
+@JvmName("extendToLong")
+public inline fun Byte.extendToLong(): Long = this.toLong()
 
 /**
  * Converts this [UByte] value to [UShort].
  *
  * The resulting [UShort] value represents the same numerical value as this [UByte].
  */
-public inline fun UByte.asUShort(): UShort = this.toUShort()
+@JvmName("extendToUShort")
+public inline fun UByte.extendToUShort(): UShort = this.toUShort()
 
 /**
  * Converts this [UByte] value to [UInt].
  *
  * The resulting [UInt] value represents the same numerical value as this [UByte].
  */
-public inline fun UByte.asUInt(): UInt = this.toUInt()
+@JvmName("extendToUInt")
+public inline fun UByte.extendToUInt(): UInt = this.toUInt()
 
 /**
  * Converts this [UByte] value to [ULong].
  *
  * The resulting [ULong] value represents the same numerical value as this [UByte].
  */
-public inline fun UByte.asULong(): ULong = this.toULong()
+@JvmName("extendToULong")
+public inline fun UByte.extendToULong(): ULong = this.toULong()
 
 /**
  * Converts this [Short] value to [Int].
  *
  * The resulting [Int] value represents the same numerical value as this [Short].
  */
-public inline fun Short.asInt(): Int = this.toInt()
+@JvmName("extendToInt")
+public inline fun Short.extendToInt(): Int = this.toInt()
 
 /**
  * Converts this [Short] value to [Long].
  *
  * The resulting [Long] value represents the same numerical value as this [Short].
  */
-public inline fun Short.asLong(): Long = this.toLong()
+@JvmName("extendToLong")
+public inline fun Short.extendToLong(): Long = this.toLong()
 
 /**
  * Converts this [UShort] value to [UInt].
  *
  * The resulting [UInt] value represents the same numerical value as this [UShort].
  */
-public inline fun UShort.asUInt(): UInt = this.toUInt()
+@JvmName("extendToUInt")
+public inline fun UShort.extendToUInt(): UInt = this.toUInt()
 
 /**
  * Converts this [UShort] value to [ULong].
  *
  * The resulting [ULong] value represents the same numerical value as this [UShort].
  */
-public inline fun UShort.asULong(): ULong = this.toULong()
+@JvmName("extendToULong")
+public inline fun UShort.extendToULong(): ULong = this.toULong()
 
 /**
  * Converts this [Int] value to [Long].
  *
  * The resulting [Long] value represents the same numerical value as this [Int].
  */
-public inline fun Int.asLong(): Long = this.toLong()
+@JvmName("extendToLong")
+public inline fun Int.extendToLong(): Long = this.toLong()
 
 /**
  * Converts this [UInt] value to [ULong].
  *
  * The resulting [ULong] value represents the same numerical value as this [UInt].
  */
-public inline fun UInt.asULong(): ULong = this.toULong()
+@JvmName("extendToULong")
+public inline fun UInt.extendToULong(): ULong = this.toULong()
 
 
 /******************************** trims (or null) ****************************/
@@ -105,7 +117,8 @@ public inline fun UInt.asULong(): ULong = this.toULong()
  * the same numerical value as this [Short].
  * Otherwise `null` returned.
  */
-public inline fun Short.asByteOrNull(): Byte? = if (this in (Byte.MIN_VALUE.asShort())..(Byte.MAX_VALUE.asShort())) this.toByte() else null
+@JvmName("toByteOrNull")
+public inline fun Short.toByteOrNull(): Byte? = if (this in (Byte.MIN_VALUE.extendToShort())..(Byte.MAX_VALUE.extendToShort())) this.toByte() else null
 
 
 /**
@@ -115,7 +128,8 @@ public inline fun Short.asByteOrNull(): Byte? = if (this in (Byte.MIN_VALUE.asSh
  * the same numerical value as this [UShort].
  * Otherwise `null` returned.
  */
-public inline fun UShort.asUByteOrNull(): UByte? = if (this <= UByte.MAX_VALUE.asUShort()) this.toUByte() else null
+@JvmName("toUByteOrNull")
+public inline fun UShort.toUByteOrNull(): UByte? = if (this <= UByte.MAX_VALUE.extendToUShort()) this.toUByte() else null
 
 
 /**
@@ -125,7 +139,8 @@ public inline fun UShort.asUByteOrNull(): UByte? = if (this <= UByte.MAX_VALUE.a
  * the same numerical value as this [Int].
  * Otherwise `null` returned.
  */
-public inline fun Int.asByteOrNull(): Byte? = if (this in (Byte.MIN_VALUE.asInt())..(Byte.MAX_VALUE.asInt())) this.toByte() else null
+@JvmName("toByteOrNull")
+public inline fun Int.toByteOrNull(): Byte? = if (this in (Byte.MIN_VALUE.extendToInt())..(Byte.MAX_VALUE.extendToInt())) this.toByte() else null
 
 /**
  * Converts this [Int] value to [Short].
@@ -134,7 +149,8 @@ public inline fun Int.asByteOrNull(): Byte? = if (this in (Byte.MIN_VALUE.asInt(
  * the same numerical value as this [Int].
  * Otherwise `null` returned.
  */
-public inline fun Int.asShortOrNull(): Short? = if (this in (Short.MIN_VALUE.asInt())..(Short.MAX_VALUE.asInt())) this.toShort() else null
+@JvmName("toShortOrNull")
+public inline fun Int.toShortOrNull(): Short? = if (this in (Short.MIN_VALUE.extendToInt())..(Short.MAX_VALUE.extendToInt())) this.toShort() else null
 
 
 /**
@@ -144,7 +160,8 @@ public inline fun Int.asShortOrNull(): Short? = if (this in (Short.MIN_VALUE.asI
  * the same numerical value as this [UInt].
  * Otherwise `null` returned.
  */
-public inline fun UInt.asUByteOrNull(): UByte? = if (this <= UByte.MAX_VALUE.asUInt()) this.toUByte() else null
+@JvmName("toUByteOrNull")
+public inline fun UInt.toUByteOrNull(): UByte? = if (this <= UByte.MAX_VALUE.extendToUInt()) this.toUByte() else null
 
 /**
  * Converts this [Int] value to [Short].
@@ -153,7 +170,8 @@ public inline fun UInt.asUByteOrNull(): UByte? = if (this <= UByte.MAX_VALUE.asU
  * the same numerical value as this [Int].
  * Otherwise `null` returned.
  */
-public inline fun UInt.asUShortOrNull(): UShort? = if (this <= UShort.MAX_VALUE.asUInt()) this.toUShort() else null
+@JvmName("toUShortOrNull")
+public inline fun UInt.toUShortOrNull(): UShort? = if (this <= UShort.MAX_VALUE.extendToUInt()) this.toUShort() else null
 
 
 /**
@@ -163,7 +181,8 @@ public inline fun UInt.asUShortOrNull(): UShort? = if (this <= UShort.MAX_VALUE.
  * the same numerical value as this [Long].
  * Otherwise `null` returned.
  */
-public inline fun Long.asByteOrNull(): Byte? = if (this in (Byte.MIN_VALUE.asLong())..(Byte.MAX_VALUE.asLong())) this.toByte() else null
+@JvmName("toByteOrNull")
+public inline fun Long.toByteOrNull(): Byte? = if (this in (Byte.MIN_VALUE.extendToLong())..(Byte.MAX_VALUE.extendToLong())) this.toByte() else null
 
 /**
  * Converts this [Long] value to [Short].
@@ -172,7 +191,8 @@ public inline fun Long.asByteOrNull(): Byte? = if (this in (Byte.MIN_VALUE.asLon
  * the same numerical value as this [Long].
  * Otherwise `null` returned.
  */
-public inline fun Long.asShortOrNull(): Short? = if (this in (Short.MIN_VALUE.asLong())..(Short.MAX_VALUE.asLong())) this.toShort() else null
+@JvmName("toShortOrNull")
+public inline fun Long.toShortOrNull(): Short? = if (this in (Short.MIN_VALUE.extendToLong())..(Short.MAX_VALUE.extendToLong())) this.toShort() else null
 
 
 /**
@@ -182,7 +202,8 @@ public inline fun Long.asShortOrNull(): Short? = if (this in (Short.MIN_VALUE.as
  * the same numerical value as this [Long].
  * Otherwise `null` returned.
  */
-public inline fun Long.asIntOrNull(): Int? = if (this in (Int.MIN_VALUE.asLong())..(Int.MAX_VALUE.asLong())) this.toInt() else null
+@JvmName("toIntOrNull")
+public inline fun Long.toIntOrNull(): Int? = if (this in (Int.MIN_VALUE.extendToLong())..(Int.MAX_VALUE.extendToLong())) this.toInt() else null
 
 
 /**
@@ -192,7 +213,8 @@ public inline fun Long.asIntOrNull(): Int? = if (this in (Int.MIN_VALUE.asLong()
  * the same numerical value as this [ULong].
  * Otherwise `null` returned.
  */
-public inline fun ULong.asUByteOrNull(): UByte? = if (this in (UByte.MIN_VALUE.asULong())..(UByte.MAX_VALUE.asULong())) this.toUByte() else null
+@JvmName("toUByteOrNull")
+public inline fun ULong.toUByteOrNull(): UByte? = if (this in (UByte.MIN_VALUE.extendToULong())..(UByte.MAX_VALUE.extendToULong())) this.toUByte() else null
 
 /**
  * Converts this [ULong] value to [UShort].
@@ -201,7 +223,8 @@ public inline fun ULong.asUByteOrNull(): UByte? = if (this in (UByte.MIN_VALUE.a
  * the same numerical value as this [ULong].
  * Otherwise `null` returned.
  */
-public inline fun ULong.asUShortOrNull(): UShort? = if (this in (UShort.MIN_VALUE.asULong())..(UShort.MAX_VALUE.asULong())) this.toUShort() else null
+@JvmName("toUShortOrNull")
+public inline fun ULong.toUShortOrNull(): UShort? = if (this in (UShort.MIN_VALUE.extendToULong())..(UShort.MAX_VALUE.extendToULong())) this.toUShort() else null
 
 
 /**
@@ -211,43 +234,58 @@ public inline fun ULong.asUShortOrNull(): UShort? = if (this in (UShort.MIN_VALU
  * the same numerical value as this [ULong].
  * Otherwise `null` returned.
  */
-public inline fun ULong.asUIntOrNull(): UInt? = if (this in (UInt.MIN_VALUE.asULong())..(UInt.MAX_VALUE.asULong())) this.toUInt() else null
+@JvmName("toUIntOrNull")
+public inline fun ULong.toUIntOrNull(): UInt? = if (this in (UInt.MIN_VALUE.extendToULong())..(UInt.MAX_VALUE.extendToULong())) this.toUInt() else null
 
 
 /********************************************* Conversion error formatters ****************************************/
 
 @Suppress("FunctionName")
+@JvmName("_formatTrimOverflowS")
 private inline fun <reified W, reified N> _formatTrimOverflowS(value: W, min: N, max: N) =
 	"Can't convert ${W::class.simpleName!!} value to ${N::class.simpleName!!} because $value !in ${min}..${max}"
 
 @Suppress("FunctionName")
+@JvmName("_formatTrimOverflowU")
 private inline fun <reified W, reified N> _formatTrimOverflowU(value: W, max: N) =
 	"Can't convert ${W::class.simpleName!!} value to ${N::class.simpleName!!} because $value > $max"
 
 
-public fun Short.formatAsByteError(): String = _formatTrimOverflowS<Short, Byte>(this, Byte.MIN_VALUE, Byte.MAX_VALUE)
+@JvmName("formatToByteError")
+public fun Short.formatToByteError(): String = _formatTrimOverflowS<Short, Byte>(this, Byte.MIN_VALUE, Byte.MAX_VALUE)
 
-public fun UShort.formatAsUByteError(): String = _formatTrimOverflowU<UShort, UByte>(this, UByte.MAX_VALUE)
+@JvmName("formatToUByteError")
+public fun UShort.formatToUByteError(): String = _formatTrimOverflowU<UShort, UByte>(this, UByte.MAX_VALUE)
 
-public fun Int.formatAsByteError(): String = _formatTrimOverflowS<Int, Byte>(this, Byte.MIN_VALUE, Byte.MAX_VALUE)
+@JvmName("formatToByteError")
+public fun Int.formatToByteError(): String = _formatTrimOverflowS<Int, Byte>(this, Byte.MIN_VALUE, Byte.MAX_VALUE)
 
-public fun Int.formatAsShortError(): String = _formatTrimOverflowS<Int, Short>(this, Short.MIN_VALUE, Short.MAX_VALUE)
+@JvmName("formatToShortError")
+public fun Int.formatToShortError(): String = _formatTrimOverflowS<Int, Short>(this, Short.MIN_VALUE, Short.MAX_VALUE)
 
-public fun UInt.formatAsUByteError(): String = _formatTrimOverflowU<UInt, UByte>(this, UByte.MAX_VALUE)
+@JvmName("formatToUByteError")
+public fun UInt.formatToUByteError(): String = _formatTrimOverflowU<UInt, UByte>(this, UByte.MAX_VALUE)
 
-public fun UInt.formatAsUShortError(): String = _formatTrimOverflowU<UInt, UShort>(this, UShort.MAX_VALUE)
+@JvmName("formatToUShortError")
+public fun UInt.formatToUShortError(): String = _formatTrimOverflowU<UInt, UShort>(this, UShort.MAX_VALUE)
 
-public fun Long.formatAsByteError(): String = _formatTrimOverflowS<Long, Byte>(this, Byte.MIN_VALUE, Byte.MAX_VALUE)
+@JvmName("formatToByteError")
+public fun Long.formatToByteError(): String = _formatTrimOverflowS<Long, Byte>(this, Byte.MIN_VALUE, Byte.MAX_VALUE)
 
-public fun Long.formatAsShortError(): String = _formatTrimOverflowS<Long, Short>(this, Short.MIN_VALUE, Short.MAX_VALUE)
+@JvmName("formatToShortError")
+public fun Long.formatToShortError(): String = _formatTrimOverflowS<Long, Short>(this, Short.MIN_VALUE, Short.MAX_VALUE)
 
-public fun Long.formatAsIntError(): String = _formatTrimOverflowS<Long, Int>(this, Int.MIN_VALUE, Int.MAX_VALUE)
+@JvmName("formatToIntError")
+public fun Long.formatToIntError(): String = _formatTrimOverflowS<Long, Int>(this, Int.MIN_VALUE, Int.MAX_VALUE)
 
-public fun ULong.formatAsUByteError(): String = _formatTrimOverflowU<ULong, UByte>(this, UByte.MAX_VALUE)
+@JvmName("formatToUByteError")
+public fun ULong.formatToUByteError(): String = _formatTrimOverflowU<ULong, UByte>(this, UByte.MAX_VALUE)
 
-public fun ULong.formatAsUShortError(): String = _formatTrimOverflowU<ULong, UShort>(this, UShort.MAX_VALUE)
+@JvmName("formatToUShortError")
+public fun ULong.formatToUShortError(): String = _formatTrimOverflowU<ULong, UShort>(this, UShort.MAX_VALUE)
 
-public fun ULong.formatAsUIntError(): String = _formatTrimOverflowU<ULong, UInt>(this, UInt.MAX_VALUE)
+@JvmName("formatToUIntError")
+public fun ULong.formatToUIntError(): String = _formatTrimOverflowU<ULong, UInt>(this, UInt.MAX_VALUE)
 
 /******************************** trims (or exception) ****************************/
 
@@ -259,12 +297,13 @@ public fun ULong.formatAsUIntError(): String = _formatTrimOverflowU<ULong, UInt>
  * the same numerical value as this [Short].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun Short.asByteOrThrow(exception: (Short) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsByteError()) }): Byte {
+@JvmName("toByteOrThrow")
+public inline fun Short.toByteOrThrow(exception: (Short) -> Nothing = { b -> throw IllegalArgumentException(b.formatToByteError()) }): Byte {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asByteOrNull() ?: exception(this)
+	return this.toByteOrNull() ?: exception(this)
 }
 
 /**
@@ -274,12 +313,13 @@ public inline fun Short.asByteOrThrow(exception: (Short) -> Nothing = { b -> thr
  * the same numerical value as this [UShort].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun UShort.asByteOrThrow(exception: (UShort) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsUByteError()) }): UByte {
+@JvmName("toByteOrThrow")
+public inline fun UShort.toByteOrThrow(exception: (UShort) -> Nothing = { b -> throw IllegalArgumentException(b.formatToUByteError()) }): UByte {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asUByteOrNull() ?: exception(this)
+	return this.toUByteOrNull() ?: exception(this)
 }
 
 /**
@@ -289,12 +329,13 @@ public inline fun UShort.asByteOrThrow(exception: (UShort) -> Nothing = { b -> t
  * the same numerical value as this [Int].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun Int.asByteOrThrow(exception: (Int) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsByteError()) }): Byte {
+@JvmName("toByteOrThrow")
+public inline fun Int.toByteOrThrow(exception: (Int) -> Nothing = { b -> throw IllegalArgumentException(b.formatToByteError()) }): Byte {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asByteOrNull() ?: exception(this)
+	return this.toByteOrNull() ?: exception(this)
 }
 
 /**
@@ -304,12 +345,13 @@ public inline fun Int.asByteOrThrow(exception: (Int) -> Nothing = { b -> throw I
  * the same numerical value as this [Int].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun Int.asShortOrThrow(exception: (Int) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsShortError()) }): Short {
+@JvmName("toShortOrThrow")
+public inline fun Int.toShortOrThrow(exception: (Int) -> Nothing = { b -> throw IllegalArgumentException(b.formatToShortError()) }): Short {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asShortOrNull() ?: exception(this)
+	return this.toShortOrNull() ?: exception(this)
 }
 
 /**
@@ -319,12 +361,13 @@ public inline fun Int.asShortOrThrow(exception: (Int) -> Nothing = { b -> throw
  * the same numerical value as this [UInt].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun UInt.asUByteOrThrow(exception: (UInt) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsUByteError()) }): UByte {
+@JvmName("toUByteOrThrow")
+public inline fun UInt.toUByteOrThrow(exception: (UInt) -> Nothing = { b -> throw IllegalArgumentException(b.formatToUByteError()) }): UByte {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asUByteOrNull() ?: exception(this)
+	return this.toUByteOrNull() ?: exception(this)
 }
 
 
@@ -335,12 +378,13 @@ public inline fun UInt.asUByteOrThrow(exception: (UInt) -> Nothing = { b -> thro
  * the same numerical value as this [UShort].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun UInt.asUShortOrThrow(exception: (UInt) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsUShortError()) }): UShort {
+@JvmName("toUShortOrThrow")
+public inline fun UInt.toUShortOrThrow(exception: (UInt) -> Nothing = { b -> throw IllegalArgumentException(b.formatToUShortError()) }): UShort {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asUShortOrNull() ?: exception(this)
+	return this.toUShortOrNull() ?: exception(this)
 }
 
 
@@ -351,12 +395,13 @@ public inline fun UInt.asUShortOrThrow(exception: (UInt) -> Nothing = { b -> thr
  * the same numerical value as this [Long].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun Long.asByteOrThrow(exception: (Long) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsByteError()) }): Byte {
+@JvmName("toByteOrThrow")
+public inline fun Long.toByteOrThrow(exception: (Long) -> Nothing = { b -> throw IllegalArgumentException(b.formatToByteError()) }): Byte {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asByteOrNull() ?: exception(this)
+	return this.toByteOrNull() ?: exception(this)
 }
 
 /**
@@ -366,12 +411,13 @@ public inline fun Long.asByteOrThrow(exception: (Long) -> Nothing = { b -> throw
  * the same numerical value as this [Long].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun Long.asShortOrThrow(exception: (Long) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsShortError()) }): Short {
+@JvmName("toShortOrThrow")
+public inline fun Long.toShortOrThrow(exception: (Long) -> Nothing = { b -> throw IllegalArgumentException(b.formatToShortError()) }): Short {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asShortOrNull() ?: exception(this)
+	return this.toShortOrNull() ?: exception(this)
 }
 
 /**
@@ -381,12 +427,13 @@ public inline fun Long.asShortOrThrow(exception: (Long) -> Nothing = { b -> thro
  * the same numerical value as this [Long].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun Long.asIntOrThrow(exception: (Long) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsIntError()) }): Int {
+@JvmName("toIntOrThrow")
+public inline fun Long.toIntOrThrow(exception: (Long) -> Nothing = { b -> throw IllegalArgumentException(b.formatToIntError()) }): Int {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asIntOrNull() ?: exception(this)
+	return this.toIntOrNull() ?: exception(this)
 }
 
 /**
@@ -396,12 +443,13 @@ public inline fun Long.asIntOrThrow(exception: (Long) -> Nothing = { b -> throw
  * the same numerical value as this [ULong].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun ULong.asUByteOrThrow(exception: (ULong) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsUByteError()) }): UByte {
+@JvmName("toUByteOrThrow")
+public inline fun ULong.toUByteOrThrow(exception: (ULong) -> Nothing = { b -> throw IllegalArgumentException(b.formatToUByteError()) }): UByte {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asUByteOrNull() ?: exception(this)
+	return this.toUByteOrNull() ?: exception(this)
 }
 
 
@@ -412,12 +460,13 @@ public inline fun ULong.asUByteOrThrow(exception: (ULong) -> Nothing = { b -> th
  * the same numerical value as this [ULong].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun ULong.asUShortOrThrow(exception: (ULong) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsUShortError()) }): UShort {
+@JvmName("toUShortOrThrow")
+public inline fun ULong.toUShortOrThrow(exception: (ULong) -> Nothing = { b -> throw IllegalArgumentException(b.formatToUShortError()) }): UShort {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asUShortOrNull() ?: exception(this)
+	return this.toUShortOrNull() ?: exception(this)
 }
 
 
@@ -428,11 +477,12 @@ public inline fun ULong.asUShortOrThrow(exception: (ULong) -> Nothing = { b -> t
  * the same numerical value as this [ULong].
  * Otherwise [exception] function called (by default throws [IllegalArgumentException]).
  */
-public inline fun ULong.asUIntOrThrow(exception: (ULong) -> Nothing = { b -> throw IllegalArgumentException(b.formatAsUIntError()) }): UInt {
+@JvmName("toUIntOrThrow")
+public inline fun ULong.toUIntOrThrow(exception: (ULong) -> Nothing = { b -> throw IllegalArgumentException(b.formatToUIntError()) }): UInt {
 	contract {
 		callsInPlace(exception, InvocationKind.AT_MOST_ONCE)
 	}
 
-	return this.asUIntOrNull() ?: exception(this)
+	return this.toUIntOrNull() ?: exception(this)
 }