rangeUntil member operator in builtins #KT-52933

This commit is contained in:
Ilya Gorbunov
2022-08-11 00:41:04 +02:00
committed by Space
parent ec9c862034
commit 203a00151d
23 changed files with 1109 additions and 97 deletions
+88
View File
@@ -1062,6 +1062,22 @@ public final class Byte : kotlin.Number, kotlin.Comparable<kotlin.Byte> {
public final operator fun rangeTo(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Byte): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Int): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Long): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.1")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
public final operator fun rem(other: kotlin.Byte): kotlin.Int
@@ -1185,6 +1201,10 @@ public final class Char : kotlin.Comparable<kotlin.Char> {
public final operator fun rangeTo(other: kotlin.Char): kotlin.ranges.CharRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Char): kotlin.ranges.CharRange
@kotlin.Deprecated(message = "Conversion of Char to Number is deprecated. Use Char.code property instead.", replaceWith = kotlin.ReplaceWith(expression = "this.code.toByte()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
@@ -1988,6 +2008,22 @@ public final class Int : kotlin.Number, kotlin.Comparable<kotlin.Int> {
public final operator fun rangeTo(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Byte): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Int): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Long): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.1")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
public final operator fun rem(other: kotlin.Byte): kotlin.Int
@@ -2241,6 +2277,22 @@ public final class Long : kotlin.Number, kotlin.Comparable<kotlin.Long> {
public final operator fun rangeTo(other: kotlin.Short): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Byte): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Int): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Long): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Short): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.1")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
/*∆*/ public final operator fun rem(other: kotlin.Byte): kotlin.Long
@@ -2623,6 +2675,22 @@ public final class Short : kotlin.Number, kotlin.Comparable<kotlin.Short> {
public final operator fun rangeTo(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Byte): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Int): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Long): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.1")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
public final operator fun rem(other: kotlin.Byte): kotlin.Int
@@ -2914,6 +2982,11 @@ public final inline class UByte : kotlin.Comparable<kotlin.UByte> {
@kotlin.internal.InlineOnly
public final inline operator fun rangeTo(other: kotlin.UByte): kotlin.ranges.UIntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public final inline operator fun rangeUntil(other: kotlin.UByte): kotlin.ranges.UIntRange
@kotlin.internal.InlineOnly
public final inline operator fun rem(other: kotlin.UByte): kotlin.UInt
@@ -3109,6 +3182,11 @@ public final inline class UInt : kotlin.Comparable<kotlin.UInt> {
@kotlin.internal.InlineOnly
public final inline operator fun rangeTo(other: kotlin.UInt): kotlin.ranges.UIntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public final inline operator fun rangeUntil(other: kotlin.UInt): kotlin.ranges.UIntRange
@kotlin.internal.InlineOnly
public final inline operator fun rem(other: kotlin.UByte): kotlin.UInt
@@ -3310,6 +3388,11 @@ public final inline class ULong : kotlin.Comparable<kotlin.ULong> {
@kotlin.internal.InlineOnly
public final inline operator fun rangeTo(other: kotlin.ULong): kotlin.ranges.ULongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public final inline operator fun rangeUntil(other: kotlin.ULong): kotlin.ranges.ULongRange
@kotlin.internal.InlineOnly
public final inline operator fun rem(other: kotlin.UByte): kotlin.ULong
@@ -3511,6 +3594,11 @@ public final inline class UShort : kotlin.Comparable<kotlin.UShort> {
@kotlin.internal.InlineOnly
public final inline operator fun rangeTo(other: kotlin.UShort): kotlin.ranges.UIntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public final inline operator fun rangeUntil(other: kotlin.UShort): kotlin.ranges.UIntRange
@kotlin.internal.InlineOnly
public final inline operator fun rem(other: kotlin.UByte): kotlin.UInt
+88
View File
@@ -990,6 +990,22 @@ public final class Byte : kotlin.Number, kotlin.Comparable<kotlin.Byte> {
public final operator fun rangeTo(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Byte): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Int): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Long): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.1")
public final operator fun rem(other: kotlin.Byte): kotlin.Int
@@ -1092,6 +1108,10 @@ public final class Char : kotlin.Comparable<kotlin.Char> {
public final operator fun rangeTo(other: kotlin.Char): kotlin.ranges.CharRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Char): kotlin.ranges.CharRange
@kotlin.Deprecated(message = "Conversion of Char to Number is deprecated. Use Char.code property instead.", replaceWith = kotlin.ReplaceWith(expression = "this.code.toByte()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
public final fun toByte(): kotlin.Byte
@@ -1750,6 +1770,22 @@ public final class Int : kotlin.Number, kotlin.Comparable<kotlin.Int> {
public final operator fun rangeTo(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Byte): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Int): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Long): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.1")
public final operator fun rem(other: kotlin.Byte): kotlin.Int
@@ -1951,6 +1987,22 @@ public final class Long : kotlin.Number, kotlin.Comparable<kotlin.Long> {
public final operator fun rangeTo(other: kotlin.Short): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Byte): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Int): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Long): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Short): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.1")
/*∆*/ public final inline operator fun rem(other: kotlin.Byte): kotlin.Long
@@ -2284,6 +2336,22 @@ public final class Short : kotlin.Number, kotlin.Comparable<kotlin.Short> {
public final operator fun rangeTo(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Byte): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Int): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Long): kotlin.ranges.LongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
public final operator fun rangeUntil(other: kotlin.Short): kotlin.ranges.IntRange
@kotlin.SinceKotlin(version = "1.1")
public final operator fun rem(other: kotlin.Byte): kotlin.Int
@@ -2551,6 +2619,11 @@ public final inline class UByte : kotlin.Comparable<kotlin.UByte> {
@kotlin.internal.InlineOnly
public final inline operator fun rangeTo(other: kotlin.UByte): kotlin.ranges.UIntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public final inline operator fun rangeUntil(other: kotlin.UByte): kotlin.ranges.UIntRange
@kotlin.internal.InlineOnly
public final inline operator fun rem(other: kotlin.UByte): kotlin.UInt
@@ -2746,6 +2819,11 @@ public final inline class UInt : kotlin.Comparable<kotlin.UInt> {
@kotlin.internal.InlineOnly
public final inline operator fun rangeTo(other: kotlin.UInt): kotlin.ranges.UIntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public final inline operator fun rangeUntil(other: kotlin.UInt): kotlin.ranges.UIntRange
@kotlin.internal.InlineOnly
public final inline operator fun rem(other: kotlin.UByte): kotlin.UInt
@@ -2947,6 +3025,11 @@ public final inline class ULong : kotlin.Comparable<kotlin.ULong> {
@kotlin.internal.InlineOnly
public final inline operator fun rangeTo(other: kotlin.ULong): kotlin.ranges.ULongRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public final inline operator fun rangeUntil(other: kotlin.ULong): kotlin.ranges.ULongRange
@kotlin.internal.InlineOnly
public final inline operator fun rem(other: kotlin.UByte): kotlin.ULong
@@ -3148,6 +3231,11 @@ public final inline class UShort : kotlin.Comparable<kotlin.UShort> {
@kotlin.internal.InlineOnly
public final inline operator fun rangeTo(other: kotlin.UShort): kotlin.ranges.UIntRange
@kotlin.SinceKotlin(version = "1.7")
@kotlin.ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public final inline operator fun rangeUntil(other: kotlin.UShort): kotlin.ranges.UIntRange
@kotlin.internal.InlineOnly
public final inline operator fun rem(other: kotlin.UByte): kotlin.UInt
@@ -0,0 +1,49 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package kotlin.ranges
// extracted from _URanges.kt to avoid bringing a lot of transitive dependencies
/**
* Returns a range from this value up to but excluding the specified [to] value.
*
* If the [to] value is less than or equal to `this` value, then the returned range is empty.
*/
public infix fun UByte.until(to: UByte): UIntRange {
if (to <= UByte.MIN_VALUE) return UIntRange.EMPTY
return this.toUInt() .. (to - 1u).toUInt()
}
/**
* Returns a range from this value up to but excluding the specified [to] value.
*
* If the [to] value is less than or equal to `this` value, then the returned range is empty.
*/
public infix fun UInt.until(to: UInt): UIntRange {
if (to <= UInt.MIN_VALUE) return UIntRange.EMPTY
return this .. (to - 1u).toUInt()
}
/**
* Returns a range from this value up to but excluding the specified [to] value.
*
* If the [to] value is less than or equal to `this` value, then the returned range is empty.
*/
public infix fun ULong.until(to: ULong): ULongRange {
if (to <= ULong.MIN_VALUE) return ULongRange.EMPTY
return this .. (to - 1u).toULong()
}
/**
* Returns a range from this value up to but excluding the specified [to] value.
*
* If the [to] value is less than or equal to `this` value, then the returned range is empty.
*/
public infix fun UShort.until(to: UShort): UIntRange {
if (to <= UShort.MIN_VALUE) return UIntRange.EMPTY
return this.toUInt() .. (to - 1u).toUInt()
}
+11 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -53,6 +53,16 @@ internal constructor(private val value: Int) : Comparable<Char> {
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Char): CharRange = CharRange(this, other)
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Char): CharRange = this until other
/** Returns the value of this character as a `Byte`. */
@Deprecated("Conversion of Char to Number is deprecated. Use Char.code property instead.", ReplaceWith("this.code.toByte()"))
@DeprecatedSinceKotlin(warningSince = "1.5")
+109 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -202,6 +202,42 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Byte): IntRange
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Short): IntRange
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Int): IntRange
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Long): LongRange
/** Returns this value. */
public override fun toByte(): Byte
/**
@@ -454,6 +490,42 @@ public class Short private constructor() : Number(), Comparable<Short> {
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Byte): IntRange
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Short): IntRange
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Int): IntRange
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Long): LongRange
/**
* Converts this [Short] value to [Byte].
*
@@ -703,6 +775,42 @@ public class Int private constructor() : Number(), Comparable<Int> {
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Byte): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Short): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Int): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Long): LongRange = this until other
/**
* Shifts this value left by the [bitCount] number of bits.
*
+37 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -233,6 +233,42 @@ public class Long internal constructor(
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange = LongRange(this, other)
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Byte): LongRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Short): LongRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Int): LongRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Long): LongRange = this until other
/**
* Shifts this value left by the [bitCount] number of bits.
*
@@ -237,6 +237,16 @@ public value class UByte @kotlin.internal.IntrinsicConstEvaluation @PublishedApi
@kotlin.internal.InlineOnly
public inline operator fun rangeTo(other: UByte): UIntRange = UIntRange(this.toUInt(), other.toUInt())
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public inline operator fun rangeUntil(other: UByte): UIntRange = this.toUInt() until other.toUInt()
/** Performs a bitwise AND operation between the two values. */
@kotlin.internal.InlineOnly
public inline infix fun and(other: UByte): UByte = UByte(this.data and other.data)
@@ -237,6 +237,16 @@ public value class UInt @kotlin.internal.IntrinsicConstEvaluation @PublishedApi
@kotlin.internal.InlineOnly
public inline operator fun rangeTo(other: UInt): UIntRange = UIntRange(this, other)
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public inline operator fun rangeUntil(other: UInt): UIntRange = this until other
/**
* Shifts this value left by the [bitCount] number of bits.
*
@@ -237,6 +237,16 @@ public value class ULong @kotlin.internal.IntrinsicConstEvaluation @PublishedApi
@kotlin.internal.InlineOnly
public inline operator fun rangeTo(other: ULong): ULongRange = ULongRange(this, other)
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public inline operator fun rangeUntil(other: ULong): ULongRange = this until other
/**
* Shifts this value left by the [bitCount] number of bits.
*
@@ -237,6 +237,16 @@ public value class UShort @kotlin.internal.IntrinsicConstEvaluation @PublishedAp
@kotlin.internal.InlineOnly
public inline operator fun rangeTo(other: UShort): UIntRange = UIntRange(this.toUInt(), other.toUInt())
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
@kotlin.internal.InlineOnly
public inline operator fun rangeUntil(other: UShort): UIntRange = this.toUInt() until other.toUInt()
/** Performs a bitwise AND operation between the two values. */
@kotlin.internal.InlineOnly
public inline infix fun and(other: UShort): UShort = UShort(this.data and other.data)
+11 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -63,6 +63,16 @@ public class Char private constructor(public val value: Char) : Comparable<Char>
public operator fun rangeTo(other: Char): CharRange =
CharRange(this, other)
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Char): CharRange =
this until other
/** Returns the value of this character as a `Byte`. */
public inline fun toByte(): Byte =
this.toInt().toByte()
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress(
@@ -233,6 +233,62 @@ public class Byte private constructor(public val value: Byte) : Number(), Compar
public inline operator fun unaryMinus(): Int =
-this.toInt()
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Byte): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Short): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Int): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange {
return LongRange(this.toLong(), other.toLong())
}
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Byte): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Short): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Int): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Long): LongRange = this until other
/** Returns this value. */
public override inline fun toByte(): Byte =
this
@@ -291,26 +347,6 @@ public class Byte private constructor(public val value: Byte) : Number(), Compar
*/
public override fun toDouble(): Double = wasm_f64_convert_i32_s(this.toInt())
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Byte): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Short): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Int): IntRange {
return IntRange(this.toInt(), other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange {
return LongRange(this.toLong(), other.toLong())
}
/** Performs a bitwise AND operation between the two values. */
@SinceKotlin("1.1")
@WasmOp(WasmOp.I32_AND)
@@ -593,6 +629,42 @@ public class Short private constructor(public val value: Short) : Number(), Comp
return LongRange(this.toLong(), other)
}
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Byte): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Short): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Int): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Long): LongRange = this until other
/** Performs a bitwise AND operation between the two values. */
@SinceKotlin("1.1")
@WasmOp(WasmOp.I32_AND)
@@ -917,6 +989,62 @@ public class Int private constructor(val value: Int) : Number(), Comparable<Int>
/** Returns the negative of this value. */
public inline operator fun unaryMinus(): Int = 0 - this
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Byte): IntRange {
return IntRange(this, other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Short): IntRange {
return IntRange(this, other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Int): IntRange {
return IntRange(this, other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange {
return LongRange(this.toLong(), other.toLong())
}
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Byte): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Short): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Int): IntRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Long): LongRange = this until other
/**
* Shifts this value left by the [bitCount] number of bits.
*
@@ -966,26 +1094,6 @@ public class Int private constructor(val value: Int) : Number(), Comparable<Int>
public inline fun inv(): Int =
this.xor(-1)
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Byte): IntRange {
return IntRange(this, other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Short): IntRange {
return IntRange(this, other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Int): IntRange {
return IntRange(this, other.toInt())
}
/** Creates a range from this value to the specified [other] value. */
public operator fun rangeTo(other: Long): LongRange {
return LongRange(this.toLong(), other.toLong())
}
/**
* Converts this [Int] value to [Byte].
*
@@ -1330,6 +1438,42 @@ public class Long private constructor(val value: Long) : Number(), Comparable<Lo
return LongRange(this, other.toLong())
}
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Byte): LongRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Short): LongRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Int): LongRange = this until other
/**
* Creates a range from this value up to but excluding the specified [other] value.
*
* If the [other] value is less than or equal to `this` value, then the returned range is empty.
*/
@SinceKotlin("1.7")
@ExperimentalStdlibApi
public operator fun rangeUntil(other: Long): LongRange = this until other
/**
* Shifts this value left by the [bitCount] number of bits.
*