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:
@@ -67,8 +67,8 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
||||
out.println("import kotlin.jvm.*")
|
||||
out.println()
|
||||
|
||||
out.println("@SinceKotlin(\"1.3\")")
|
||||
out.println("@ExperimentalUnsignedTypes")
|
||||
out.println("@SinceKotlin(\"1.5\")")
|
||||
out.println("@WasExperimental(ExperimentalUnsignedTypes::class)")
|
||||
out.println("@JvmInline")
|
||||
out.println("public value class $className @PublishedApi internal constructor(@PublishedApi internal val data: $storageType) : Comparable<$className> {")
|
||||
out.println()
|
||||
@@ -384,8 +384,8 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
||||
}
|
||||
}
|
||||
out.println(" */")
|
||||
out.println("@SinceKotlin(\"1.3\")")
|
||||
out.println("@ExperimentalUnsignedTypes")
|
||||
out.println("@SinceKotlin(\"1.5\")")
|
||||
out.println("@WasExperimental(ExperimentalUnsignedTypes::class)")
|
||||
out.println("@kotlin.internal.InlineOnly")
|
||||
out.print("public inline fun $otherSigned.to$className(): $className = ")
|
||||
out.println(when {
|
||||
@@ -411,8 +411,8 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns
|
||||
*/
|
||||
""".trimIndent()
|
||||
)
|
||||
out.println("@SinceKotlin(\"1.3\")")
|
||||
out.println("@ExperimentalUnsignedTypes")
|
||||
out.println("@SinceKotlin(\"1.5\")")
|
||||
out.println("@WasExperimental(ExperimentalUnsignedTypes::class)")
|
||||
out.println("@kotlin.internal.InlineOnly")
|
||||
out.print("public inline fun $otherName.to$className(): $className = ")
|
||||
val conversion = if (otherType == PrimitiveType.DOUBLE) "" else ".toDouble()"
|
||||
@@ -452,11 +452,10 @@ class UnsignedIteratorsGenerator(out: PrintWriter) : BuiltInsSourceGenerator(out
|
||||
for (type in UnsignedType.values()) {
|
||||
val s = type.capitalized
|
||||
out.println("/** An iterator over a sequence of values of type `$s`. */")
|
||||
out.println("@Deprecated(\"This class is not going to be stabilized and is to be removed soon.\", level = DeprecationLevel.ERROR)")
|
||||
out.println("@SinceKotlin(\"1.3\")")
|
||||
out.println("@ExperimentalUnsignedTypes")
|
||||
out.println("public abstract class ${s}Iterator : Iterator<$s> {")
|
||||
// TODO: Sort modifiers
|
||||
out.println(" override final fun next() = next$s()")
|
||||
out.println(" final override fun next() = next$s()")
|
||||
out.println()
|
||||
out.println(" /** Returns the next value in the sequence without boxing. */")
|
||||
out.println(" public abstract fun next$s(): $s")
|
||||
@@ -509,8 +508,9 @@ class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIn
|
||||
public override val size: Int get() = storage.size
|
||||
|
||||
/** Creates an iterator over the elements of the array. */
|
||||
public override operator fun iterator(): ${elementType}Iterator = Iterator(storage)
|
||||
public override operator fun iterator(): kotlin.collections.Iterator<$elementType> = Iterator(storage)
|
||||
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
private class Iterator(private val array: $storageArrayType) : ${elementType}Iterator() {
|
||||
private var index = 0
|
||||
override fun hasNext() = index < array.size
|
||||
@@ -579,8 +579,8 @@ import kotlin.internal.*
|
||||
/**
|
||||
* A range of values of type `$elementType`.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public class ${elementType}Range(start: $elementType, endInclusive: $elementType) : ${elementType}Progression(start, endInclusive, 1), ClosedRange<${elementType}> {
|
||||
override val start: $elementType get() = first
|
||||
override val endInclusive: $elementType get() = last
|
||||
@@ -612,8 +612,8 @@ public class ${elementType}Range(start: $elementType, endInclusive: $elementType
|
||||
/**
|
||||
* A progression of values of type `$elementType`.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@SinceKotlin("1.5")
|
||||
@WasExperimental(ExperimentalUnsignedTypes::class)
|
||||
public open class ${elementType}Progression
|
||||
internal constructor(
|
||||
start: $elementType,
|
||||
@@ -640,7 +640,7 @@ internal constructor(
|
||||
*/
|
||||
public val step: $stepType = step
|
||||
|
||||
override fun iterator(): ${elementType}Iterator = ${elementType}ProgressionIterator(first, last, step)
|
||||
final override fun iterator(): Iterator<$elementType> = ${elementType}ProgressionIterator(first, last, step)
|
||||
|
||||
/**
|
||||
* Checks if the progression is empty.
|
||||
@@ -678,7 +678,7 @@ internal constructor(
|
||||
* @property step the number by which the value is incremented on each step.
|
||||
*/
|
||||
@SinceKotlin("1.3")
|
||||
@ExperimentalUnsignedTypes
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
private class ${elementType}ProgressionIterator(first: $elementType, last: $elementType, step: $stepType) : ${elementType}Iterator() {
|
||||
private val finalElement = last
|
||||
private var hasNext: Boolean = if (step > 0) first <= last else first >= last
|
||||
|
||||
Reference in New Issue
Block a user