rangeUntil member operator in builtins #KT-52933
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
* 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("NOTHING_TO_INLINE")
|
||||
|
||||
@@ -53,6 +53,15 @@ public class Char private constructor() : Comparable<Char> {
|
||||
return 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")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
* 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("OVERRIDE_BY_INLINE", "NOTHING_TO_INLINE")
|
||||
|
||||
@@ -221,6 +221,62 @@ public final class Byte private constructor() : Number(), Comparable<Byte> {
|
||||
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 inline override fun toByte(): Byte =
|
||||
this
|
||||
@@ -281,22 +337,6 @@ public final class Byte private constructor() : Number(), Comparable<Byte> {
|
||||
@TypedIntrinsic(IntrinsicType.SIGNED_TO_FLOAT)
|
||||
external public override fun toDouble(): Double
|
||||
|
||||
/** 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())
|
||||
}
|
||||
|
||||
// Konan-specific.
|
||||
public fun equals(other: Byte): Boolean = kotlin.native.internal.areEqualByValue(this, other)
|
||||
@@ -541,6 +581,42 @@ public final class Short private constructor() : Number(), Comparable<Short> {
|
||||
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
|
||||
|
||||
/**
|
||||
* Converts this [Short] value to [Byte].
|
||||
*
|
||||
@@ -826,6 +902,62 @@ public final class Int private constructor() : Number(), Comparable<Int> {
|
||||
@TypedIntrinsic(IntrinsicType.UNARY_MINUS)
|
||||
external public operator fun unaryMinus(): Int
|
||||
|
||||
/** 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.
|
||||
*
|
||||
@@ -866,23 +998,6 @@ public final class Int private constructor() : Number(), Comparable<Int> {
|
||||
@TypedIntrinsic(IntrinsicType.INV)
|
||||
external public fun inv(): Int
|
||||
|
||||
/** 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].
|
||||
*
|
||||
@@ -1187,6 +1302,42 @@ public final class Long private constructor() : Number(), Comparable<Long> {
|
||||
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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user