Stabilize unsigned types KT-45653
Deprecate specialized unsigned iterators for removal. Fix compiler tests: - drop unsignedLiteralsOn1_2 because apiVersion 1.2 is no longer supported - drop experimental unsigned literals diagnostic test
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2021 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.
|
||||
*/
|
||||
|
||||
@@ -15,7 +15,6 @@ package kotlin
|
||||
*
|
||||
* @sample samples.text.Chars.charFromCode
|
||||
*/
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@ExperimentalStdlibApi
|
||||
@SinceKotlin("1.4")
|
||||
@kotlin.internal.InlineOnly
|
||||
@@ -31,7 +30,6 @@ public inline fun Char(code: Int): Char {
|
||||
*
|
||||
* @sample samples.text.Chars.charFromCode
|
||||
*/
|
||||
@OptIn(ExperimentalUnsignedTypes::class)
|
||||
@ExperimentalStdlibApi
|
||||
@SinceKotlin("1.4")
|
||||
@Suppress("NO_ACTUAL_FOR_EXPECT")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2021 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.
|
||||
*/
|
||||
|
||||
@@ -11,8 +11,8 @@ package kotlin.random
|
||||
*
|
||||
* Generates a [UInt] random value uniformly distributed between [UInt.MIN_VALUE] and [UInt.MAX_VALUE] (inclusive).
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public fun Random.nextUInt(): UInt = nextInt().toUInt()
|
||||
|
||||
/**
|
||||
@@ -22,8 +22,8 @@ public fun Random.nextUInt(): UInt = nextInt().toUInt()
|
||||
*
|
||||
* @throws IllegalArgumentException if [until] is zero.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public fun Random.nextUInt(until: UInt): UInt = nextUInt(0u, until)
|
||||
|
||||
/**
|
||||
@@ -33,8 +33,8 @@ public fun Random.nextUInt(until: UInt): UInt = nextUInt(0u, until)
|
||||
*
|
||||
* @throws IllegalArgumentException if [from] is greater than or equal to [until].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public fun Random.nextUInt(from: UInt, until: UInt): UInt {
|
||||
checkUIntRangeBounds(from, until)
|
||||
|
||||
@@ -53,8 +53,8 @@ public fun Random.nextUInt(from: UInt, until: UInt): UInt {
|
||||
*
|
||||
* @throws IllegalArgumentException if [range] is empty.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public fun Random.nextUInt(range: UIntRange): UInt = when {
|
||||
range.isEmpty() -> throw IllegalArgumentException("Cannot get random in empty range: $range")
|
||||
range.last < UInt.MAX_VALUE -> nextUInt(range.first, range.last + 1u)
|
||||
@@ -67,8 +67,8 @@ public fun Random.nextUInt(range: UIntRange): UInt = when {
|
||||
*
|
||||
* Generates a [ULong] random value uniformly distributed between [ULong.MIN_VALUE] and [ULong.MAX_VALUE] (inclusive).
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public fun Random.nextULong(): ULong = nextLong().toULong()
|
||||
|
||||
/**
|
||||
@@ -78,8 +78,8 @@ public fun Random.nextULong(): ULong = nextLong().toULong()
|
||||
*
|
||||
* @throws IllegalArgumentException if [until] is zero.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public fun Random.nextULong(until: ULong): ULong = nextULong(0uL, until)
|
||||
|
||||
/**
|
||||
@@ -89,8 +89,8 @@ public fun Random.nextULong(until: ULong): ULong = nextULong(0uL, until)
|
||||
*
|
||||
* @throws IllegalArgumentException if [from] is greater than or equal to [until].
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public fun Random.nextULong(from: ULong, until: ULong): ULong {
|
||||
checkULongRangeBounds(from, until)
|
||||
|
||||
@@ -109,8 +109,8 @@ public fun Random.nextULong(from: ULong, until: ULong): ULong {
|
||||
*
|
||||
* @throws IllegalArgumentException if [range] is empty.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public fun Random.nextULong(range: ULongRange): ULong = when {
|
||||
range.isEmpty() -> throw IllegalArgumentException("Cannot get random in empty range: $range")
|
||||
range.last < ULong.MAX_VALUE -> nextULong(range.first, range.last + 1u)
|
||||
@@ -150,7 +150,5 @@ public fun Random.nextUBytes(array: UByteArray, fromIndex: Int = 0, toIndex: Int
|
||||
}
|
||||
|
||||
|
||||
@ExperimentalUnsignedTypes
|
||||
internal fun checkUIntRangeBounds(from: UInt, until: UInt) = require(until > from) { boundsErrorMessage(from, until) }
|
||||
@ExperimentalUnsignedTypes
|
||||
internal fun checkULongRangeBounds(from: ULong, until: ULong) = require(until > from) { boundsErrorMessage(from, until) }
|
||||
|
||||
Reference in New Issue
Block a user