From 203a00151df1dd6e7b770e3bb662e0064c848b7f Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 11 Aug 2022 00:41:04 +0200 Subject: [PATCH] rangeUntil member operator in builtins #KT-52933 --- .../testData/builtIns/kotlin.txt | 34 +++ .../builtin-classes/default/kotlin.txt | 17 ++ .../testData/builtin-classes/java6/kotlin.txt | 17 ++ .../testData/builtin-classes/java8/kotlin.txt | 17 ++ .../builtin-classes/newMethods/kotlin.txt | 17 ++ core/builtins/native/kotlin/Char.kt | 24 +- core/builtins/native/kotlin/Primitives.kt | 144 +++++++++++ generators/builtins/primitives.kt | 20 +- generators/builtins/unsignedTypes.kt | 19 +- .../runtime/src/main/kotlin/kotlin/Char.kt | 13 +- .../src/main/kotlin/kotlin/Primitives.kt | 221 ++++++++++++++--- libraries/stdlib/api/js-v1/kotlin.kt | 88 +++++++ libraries/stdlib/api/js/kotlin.kt | 88 +++++++ .../src/smallRuntimeRanges.kt | 49 ++++ libraries/stdlib/js-ir/builtins/Char.kt | 12 +- libraries/stdlib/js-ir/builtins/Primitives.kt | 110 ++++++++- libraries/stdlib/js-ir/runtime/long.kt | 38 ++- libraries/stdlib/unsigned/src/kotlin/UByte.kt | 10 + libraries/stdlib/unsigned/src/kotlin/UInt.kt | 10 + libraries/stdlib/unsigned/src/kotlin/ULong.kt | 10 + .../stdlib/unsigned/src/kotlin/UShort.kt | 10 + libraries/stdlib/wasm/builtins/kotlin/Char.kt | 12 +- .../stdlib/wasm/builtins/kotlin/Primitives.kt | 226 ++++++++++++++---- 23 files changed, 1109 insertions(+), 97 deletions(-) create mode 100644 libraries/stdlib/js-ir-minimal-for-test/src/smallRuntimeRanges.kt diff --git a/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt b/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt index 20bd7664a1b..75f3cae9fa4 100644 --- a/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt +++ b/compiler/fir/analysis-tests/testData/builtIns/kotlin.txt @@ -180,6 +180,14 @@ public final class Byte : R|kotlin/Number|, R|kotlin/Comparable|, R public final operator fun rangeTo(other: R|kotlin/Short|): R|kotlin/ranges/IntRange| + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Byte|): R|kotlin/ranges/IntRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Int|): R|kotlin/ranges/IntRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Long|): R|kotlin/ranges/LongRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Short|): R|kotlin/ranges/IntRange| + @R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/IntrinsicConstEvaluation|() public final operator fun rem(other: R|kotlin/Byte|): R|kotlin/Int| @R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/IntrinsicConstEvaluation|() public final operator fun rem(other: R|kotlin/Double|): R|kotlin/Double| @@ -298,6 +306,8 @@ public final class Char : R|kotlin/Comparable|, R|java/io/Serializa public final operator fun rangeTo(other: R|kotlin/Char|): R|kotlin/ranges/CharRange| + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Char|): R|kotlin/ranges/CharRange| + @R|kotlin/Deprecated|(message = String(Conversion of Char to Number is deprecated. Use Char.code property instead.), replaceWith = @R|kotlin/ReplaceWith|(imports = (), expression = String(this.code.toByte())) ) @R|kotlin/DeprecatedSinceKotlin|(warningSince = String(1.5)) @R|kotlin/internal/IntrinsicConstEvaluation|() public final fun toByte(): R|kotlin/Byte| @R|kotlin/internal/IntrinsicConstEvaluation|() public final fun toChar(): R|kotlin/Char| @@ -828,6 +838,14 @@ public final class Int : R|kotlin/Number|, R|kotlin/Comparable|, R|j public final operator fun rangeTo(other: R|kotlin/Short|): R|kotlin/ranges/IntRange| + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Byte|): R|kotlin/ranges/IntRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Int|): R|kotlin/ranges/IntRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Long|): R|kotlin/ranges/LongRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Short|): R|kotlin/ranges/IntRange| + @R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/IntrinsicConstEvaluation|() public final operator fun rem(other: R|kotlin/Byte|): R|kotlin/Int| @R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/IntrinsicConstEvaluation|() public final operator fun rem(other: R|kotlin/Double|): R|kotlin/Double| @@ -988,6 +1006,14 @@ public final class Long : R|kotlin/Number|, R|kotlin/Comparable|, R public final operator fun rangeTo(other: R|kotlin/Short|): R|kotlin/ranges/LongRange| + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Byte|): R|kotlin/ranges/LongRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Int|): R|kotlin/ranges/LongRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Long|): R|kotlin/ranges/LongRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Short|): R|kotlin/ranges/LongRange| + @R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/IntrinsicConstEvaluation|() public final operator fun rem(other: R|kotlin/Byte|): R|kotlin/Long| @R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/IntrinsicConstEvaluation|() public final operator fun rem(other: R|kotlin/Double|): R|kotlin/Double| @@ -1190,6 +1216,14 @@ public final class Short : R|kotlin/Number|, R|kotlin/Comparable|, public final operator fun rangeTo(other: R|kotlin/Short|): R|kotlin/ranges/IntRange| + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Byte|): R|kotlin/ranges/IntRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Int|): R|kotlin/ranges/IntRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Long|): R|kotlin/ranges/LongRange| + + @R|kotlin/SinceKotlin|(version = String(1.7)) @R|kotlin/ExperimentalStdlibApi|() public final operator fun rangeUntil(other: R|kotlin/Short|): R|kotlin/ranges/IntRange| + @R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/IntrinsicConstEvaluation|() public final operator fun rem(other: R|kotlin/Byte|): R|kotlin/Int| @R|kotlin/SinceKotlin|(version = String(1.1)) @R|kotlin/internal/IntrinsicConstEvaluation|() public final operator fun rem(other: R|kotlin/Double|): R|kotlin/Double| diff --git a/compiler/testData/builtin-classes/default/kotlin.txt b/compiler/testData/builtin-classes/default/kotlin.txt index bb9426d2526..d404acc76af 100644 --- a/compiler/testData/builtin-classes/default/kotlin.txt +++ b/compiler/testData/builtin-classes/default/kotlin.txt @@ -87,6 +87,10 @@ public final class Byte : kotlin.Number, kotlin.Comparable { public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -141,6 +145,7 @@ public final class Char : kotlin.Comparable { @kotlin.internal.IntrinsicConstEvaluation public final operator fun minus(/*0*/ other: kotlin.Int): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public final operator fun plus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun rangeTo(/*0*/ other: kotlin.Char): kotlin.ranges.CharRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ 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 public final fun toByte(): kotlin.Byte @kotlin.internal.IntrinsicConstEvaluation public final fun toChar(): kotlin.Char @kotlin.Deprecated(message = "Conversion of Char to Number is deprecated. Use Char.code property instead.", replaceWith = kotlin.ReplaceWith(expression = "this.code.toDouble()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public final fun toDouble(): kotlin.Double @@ -463,6 +468,10 @@ public final class Int : kotlin.Number, kotlin.Comparable { public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -547,6 +556,10 @@ public final class Long : kotlin.Number, kotlin.Comparable { public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.LongRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Long @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -661,6 +674,10 @@ public final class Short : kotlin.Number, kotlin.Comparable { public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float diff --git a/compiler/testData/builtin-classes/java6/kotlin.txt b/compiler/testData/builtin-classes/java6/kotlin.txt index 2c592292804..5af69c2e0c8 100644 --- a/compiler/testData/builtin-classes/java6/kotlin.txt +++ b/compiler/testData/builtin-classes/java6/kotlin.txt @@ -89,6 +89,10 @@ public final class Byte : kotlin.Number, kotlin.Comparable, java.io public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -144,6 +148,7 @@ public final class Char : kotlin.Comparable, java.io.Serializable { @kotlin.internal.IntrinsicConstEvaluation public final operator fun minus(/*0*/ other: kotlin.Int): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public final operator fun plus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun rangeTo(/*0*/ other: kotlin.Char): kotlin.ranges.CharRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ 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 public final fun toByte(): kotlin.Byte @kotlin.internal.IntrinsicConstEvaluation public final fun toChar(): kotlin.Char @kotlin.Deprecated(message = "Conversion of Char to Number is deprecated. Use Char.code property instead.", replaceWith = kotlin.ReplaceWith(expression = "this.code.toDouble()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public final fun toDouble(): kotlin.Double @@ -477,6 +482,10 @@ public final class Int : kotlin.Number, kotlin.Comparable, java.io.S public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -562,6 +571,10 @@ public final class Long : kotlin.Number, kotlin.Comparable, java.io public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.LongRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Long @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -677,6 +690,10 @@ public final class Short : kotlin.Number, kotlin.Comparable, java. public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float diff --git a/compiler/testData/builtin-classes/java8/kotlin.txt b/compiler/testData/builtin-classes/java8/kotlin.txt index 58015f69981..73fff53fba5 100644 --- a/compiler/testData/builtin-classes/java8/kotlin.txt +++ b/compiler/testData/builtin-classes/java8/kotlin.txt @@ -89,6 +89,10 @@ public final class Byte : kotlin.Number, kotlin.Comparable, java.io public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -144,6 +148,7 @@ public final class Char : kotlin.Comparable, java.io.Serializable { @kotlin.internal.IntrinsicConstEvaluation public final operator fun minus(/*0*/ other: kotlin.Int): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public final operator fun plus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun rangeTo(/*0*/ other: kotlin.Char): kotlin.ranges.CharRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ 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 public final fun toByte(): kotlin.Byte @kotlin.internal.IntrinsicConstEvaluation public final fun toChar(): kotlin.Char @kotlin.Deprecated(message = "Conversion of Char to Number is deprecated. Use Char.code property instead.", replaceWith = kotlin.ReplaceWith(expression = "this.code.toDouble()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public final fun toDouble(): kotlin.Double @@ -479,6 +484,10 @@ public final class Int : kotlin.Number, kotlin.Comparable, java.io.S public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -564,6 +573,10 @@ public final class Long : kotlin.Number, kotlin.Comparable, java.io public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.LongRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Long @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -679,6 +692,10 @@ public final class Short : kotlin.Number, kotlin.Comparable, java. public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float diff --git a/compiler/testData/builtin-classes/newMethods/kotlin.txt b/compiler/testData/builtin-classes/newMethods/kotlin.txt index b39e96623c1..95aa6928ee0 100644 --- a/compiler/testData/builtin-classes/newMethods/kotlin.txt +++ b/compiler/testData/builtin-classes/newMethods/kotlin.txt @@ -89,6 +89,10 @@ public final class Byte : kotlin.Number, kotlin.Comparable, java.io public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -144,6 +148,7 @@ public final class Char : kotlin.Comparable, java.io.Serializable { @kotlin.internal.IntrinsicConstEvaluation public final operator fun minus(/*0*/ other: kotlin.Int): kotlin.Char @kotlin.internal.IntrinsicConstEvaluation public final operator fun plus(/*0*/ other: kotlin.Int): kotlin.Char public final operator fun rangeTo(/*0*/ other: kotlin.Char): kotlin.ranges.CharRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ 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 public final fun toByte(): kotlin.Byte @kotlin.internal.IntrinsicConstEvaluation public final fun toChar(): kotlin.Char @kotlin.Deprecated(message = "Conversion of Char to Number is deprecated. Use Char.code property instead.", replaceWith = kotlin.ReplaceWith(expression = "this.code.toDouble()", imports = {})) @kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.IntrinsicConstEvaluation public final fun toDouble(): kotlin.Double @@ -477,6 +482,10 @@ public final class Int : kotlin.Number, kotlin.Comparable, java.io.S public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -562,6 +571,10 @@ public final class Long : kotlin.Number, kotlin.Comparable, java.io public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.LongRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Long @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float @@ -677,6 +690,10 @@ public final class Short : kotlin.Number, kotlin.Comparable, java. public final operator fun rangeTo(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange public final operator fun rangeTo(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange public final operator fun rangeTo(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Byte): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Int): kotlin.ranges.IntRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Long): kotlin.ranges.LongRange + @kotlin.SinceKotlin(version = "1.7") @kotlin.ExperimentalStdlibApi public final operator fun rangeUntil(/*0*/ other: kotlin.Short): kotlin.ranges.IntRange @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Byte): kotlin.Int @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Double): kotlin.Double @kotlin.SinceKotlin(version = "1.1") @kotlin.internal.IntrinsicConstEvaluation public final operator fun rem(/*0*/ other: kotlin.Float): kotlin.Float diff --git a/core/builtins/native/kotlin/Char.kt b/core/builtins/native/kotlin/Char.kt index 0814acace32..ddb6acd4a2f 100644 --- a/core/builtins/native/kotlin/Char.kt +++ b/core/builtins/native/kotlin/Char.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * 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 @@ -59,6 +48,15 @@ public class Char private constructor() : Comparable { /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Char): CharRange + /** + * 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 + /** 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") diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index 972f31e2045..d2460cbcfd8 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -239,6 +239,42 @@ public class Byte private constructor() : Number(), Comparable { /** 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. */ @kotlin.internal.IntrinsicConstEvaluation public override fun toByte(): Byte @@ -538,6 +574,42 @@ public class Short private constructor() : Number(), Comparable { /** 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]. * @@ -835,6 +907,42 @@ public class Int private constructor() : Number(), Comparable { /** 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 + /** * Shifts this value left by the [bitCount] number of bits. * @@ -1174,6 +1282,42 @@ public class Long private constructor() : Number(), Comparable { /** 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): 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: Short): 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: Int): 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: Long): LongRange + /** * Shifts this value left by the [bitCount] number of bits. * diff --git a/generators/builtins/primitives.kt b/generators/builtins/primitives.kt index 34d6300b8ba..dd634ced053 100644 --- a/generators/builtins/primitives.kt +++ b/generators/builtins/primitives.kt @@ -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. */ @@ -178,6 +178,7 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { generateBinaryOperators(kind) generateUnaryOperators(kind) generateRangeTo(kind) + generateRangeUntil(kind) if (kind == PrimitiveType.INT || kind == PrimitiveType.LONG) { generateBitShiftOperators(kind) @@ -250,6 +251,23 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { } + private fun generateRangeUntil(thisKind: PrimitiveType) { + for (otherKind in PrimitiveType.onlyNumeric) { + val returnType = maxByDomainCapacity(maxByDomainCapacity(thisKind, otherKind), PrimitiveType.INT) + if (returnType == PrimitiveType.DOUBLE || returnType == PrimitiveType.FLOAT) + continue + out.println(" /**") + out.println(" * Creates a range from this value up to but excluding the specified [other] value.") + out.println(" *") + out.println(" * If the [other] value is less than or equal to `this` value, then the returned range is empty.") + out.println(" */") + out.println(" @SinceKotlin(\"1.7\")") + out.println(" @ExperimentalStdlibApi") + out.println(" public operator fun rangeUntil(other: ${otherKind.capitalized}): ${returnType.capitalized}Range") + out.println() + } + } + private fun generateUnaryOperators(kind: PrimitiveType) { for (name in listOf("inc", "dec")) { out.println(incDecOperatorsDoc(name).replaceIndent(" ")) diff --git a/generators/builtins/unsignedTypes.kt b/generators/builtins/unsignedTypes.kt index 34e313c52ff..06c59d1c2ea 100644 --- a/generators/builtins/unsignedTypes.kt +++ b/generators/builtins/unsignedTypes.kt @@ -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. */ @@ -96,6 +96,7 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns generateBinaryOperators() generateUnaryOperators() generateRangeTo() + generateRangeUntil() if (type == UnsignedType.UINT || type == UnsignedType.ULONG) { generateBitShiftOperators() @@ -219,6 +220,22 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns out.println() } + private fun generateRangeUntil() { + val rangeElementType = maxByDomainCapacity(type, UnsignedType.UINT) + val rangeType = rangeElementType.capitalized + "Range" + fun convert(name: String) = if (rangeElementType == type) name else "$name.to${rangeElementType.capitalized}()" + out.println(" /**") + out.println(" * Creates a range from this value up to but excluding the specified [other] value.") + out.println(" *") + out.println(" * If the [other] value is less than or equal to `this` value, then the returned range is empty.") + out.println(" */") + out.println(" @SinceKotlin(\"1.7\")") + out.println(" @ExperimentalStdlibApi") + out.println(" @kotlin.internal.InlineOnly") + out.println(" public inline operator fun rangeUntil(other: $className): $rangeType = ${convert("this")} until ${convert("other")}") + out.println() + } + private fun generateBitShiftOperators() { diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Char.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Char.kt index fda553f8f31..fd5179d0f16 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Char.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Char.kt @@ -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 { 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") diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt index f31ba2016e6..f1aa721ca53 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/Primitives.kt @@ -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 { 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 { @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 { 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 { @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 { @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 { 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. * diff --git a/libraries/stdlib/api/js-v1/kotlin.kt b/libraries/stdlib/api/js-v1/kotlin.kt index b74ef02ec44..f94a226e0ed 100644 --- a/libraries/stdlib/api/js-v1/kotlin.kt +++ b/libraries/stdlib/api/js-v1/kotlin.kt @@ -1062,6 +1062,22 @@ public final class Byte : kotlin.Number, kotlin.Comparable { 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 { 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 { 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 { 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 { 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.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.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.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.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 diff --git a/libraries/stdlib/api/js/kotlin.kt b/libraries/stdlib/api/js/kotlin.kt index 62526c38e9e..47826b164d8 100644 --- a/libraries/stdlib/api/js/kotlin.kt +++ b/libraries/stdlib/api/js/kotlin.kt @@ -990,6 +990,22 @@ public final class Byte : kotlin.Number, kotlin.Comparable { 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 { 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 { 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 { 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 { 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.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.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.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.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 diff --git a/libraries/stdlib/js-ir-minimal-for-test/src/smallRuntimeRanges.kt b/libraries/stdlib/js-ir-minimal-for-test/src/smallRuntimeRanges.kt new file mode 100644 index 00000000000..277c0d71b19 --- /dev/null +++ b/libraries/stdlib/js-ir-minimal-for-test/src/smallRuntimeRanges.kt @@ -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() +} \ No newline at end of file diff --git a/libraries/stdlib/js-ir/builtins/Char.kt b/libraries/stdlib/js-ir/builtins/Char.kt index 74bfb1d7762..2e9c6ed3644 100644 --- a/libraries/stdlib/js-ir/builtins/Char.kt +++ b/libraries/stdlib/js-ir/builtins/Char.kt @@ -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 { /** 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") diff --git a/libraries/stdlib/js-ir/builtins/Primitives.kt b/libraries/stdlib/js-ir/builtins/Primitives.kt index 002d02f7641..c5b7d216701 100644 --- a/libraries/stdlib/js-ir/builtins/Primitives.kt +++ b/libraries/stdlib/js-ir/builtins/Primitives.kt @@ -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 { /** 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 { /** 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 { /** 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. * diff --git a/libraries/stdlib/js-ir/runtime/long.kt b/libraries/stdlib/js-ir/runtime/long.kt index 9d623cd062d..04d485f1277 100644 --- a/libraries/stdlib/js-ir/runtime/long.kt +++ b/libraries/stdlib/js-ir/runtime/long.kt @@ -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. * diff --git a/libraries/stdlib/unsigned/src/kotlin/UByte.kt b/libraries/stdlib/unsigned/src/kotlin/UByte.kt index 0185ec405d6..851c363fc8e 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UByte.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UByte.kt @@ -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) diff --git a/libraries/stdlib/unsigned/src/kotlin/UInt.kt b/libraries/stdlib/unsigned/src/kotlin/UInt.kt index aeff9047529..56a1f545d52 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UInt.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UInt.kt @@ -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. * diff --git a/libraries/stdlib/unsigned/src/kotlin/ULong.kt b/libraries/stdlib/unsigned/src/kotlin/ULong.kt index 63225a3fb69..a9397bcd96a 100644 --- a/libraries/stdlib/unsigned/src/kotlin/ULong.kt +++ b/libraries/stdlib/unsigned/src/kotlin/ULong.kt @@ -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. * diff --git a/libraries/stdlib/unsigned/src/kotlin/UShort.kt b/libraries/stdlib/unsigned/src/kotlin/UShort.kt index cfb7d3fcfb3..a4a055be5ba 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UShort.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UShort.kt @@ -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) diff --git a/libraries/stdlib/wasm/builtins/kotlin/Char.kt b/libraries/stdlib/wasm/builtins/kotlin/Char.kt index 7b1d9838385..d09a19ad8b7 100644 --- a/libraries/stdlib/wasm/builtins/kotlin/Char.kt +++ b/libraries/stdlib/wasm/builtins/kotlin/Char.kt @@ -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 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() diff --git a/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt b/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt index d03ec2fe507..4d51ef692ef 100644 --- a/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt +++ b/libraries/stdlib/wasm/builtins/kotlin/Primitives.kt @@ -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 /** 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 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