From 2303730d579f01ce2624cea76149bde83fbebc79 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 8 Apr 2022 08:01:39 +0300 Subject: [PATCH] Remove deprecated and not stabilized primitive unsigned iterators --- generators/builtins/unsignedTypes.kt | 34 ++----------- .../stdlib/api/js-v1/kotlin.collections.kt | 44 +---------------- libraries/stdlib/api/js/kotlin.collections.kt | 40 --------------- .../stdlib/unsigned/src/kotlin/UByteArray.kt | 5 +- .../stdlib/unsigned/src/kotlin/UIntArray.kt | 5 +- .../stdlib/unsigned/src/kotlin/UIntRange.kt | 5 +- .../stdlib/unsigned/src/kotlin/UIterators.kt | 49 ------------------- .../stdlib/unsigned/src/kotlin/ULongArray.kt | 5 +- .../stdlib/unsigned/src/kotlin/ULongRange.kt | 5 +- .../stdlib/unsigned/src/kotlin/UShortArray.kt | 5 +- .../kotlin-stdlib-runtime-merged.txt | 32 ------------ 11 files changed, 18 insertions(+), 211 deletions(-) delete mode 100644 libraries/stdlib/unsigned/src/kotlin/UIterators.kt diff --git a/generators/builtins/unsignedTypes.kt b/generators/builtins/unsignedTypes.kt index 103957cc20e..f7d37728134 100644 --- a/generators/builtins/unsignedTypes.kt +++ b/generators/builtins/unsignedTypes.kt @@ -26,10 +26,6 @@ fun generateUnsignedTypes( for (type in listOf(UnsignedType.UINT, UnsignedType.ULONG)) { generate(File(targetDir, "kotlin/${type.capitalized}Range.kt")) { UnsignedRangeGenerator(type, it) } } - - generate(File(targetDir, "kotlin/UIterators.kt"), ::UnsignedIteratorsGenerator) - - } class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltInsSourceGenerator(out) { @@ -444,26 +440,6 @@ class UnsignedTypeGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIns } -// TODO: reuse generator -class UnsignedIteratorsGenerator(out: PrintWriter) : BuiltInsSourceGenerator(out) { - override fun getPackage() = "kotlin.collections" - override fun generateBody() { - 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("public abstract class ${s}Iterator : Iterator<$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") - out.println("}") - out.println() - } - } -} - class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltInsSourceGenerator(out) { val elementType = type.capitalized val arrayType = elementType + "Array" @@ -509,11 +485,10 @@ class UnsignedArrayGenerator(val type: UnsignedType, out: PrintWriter) : BuiltIn /** Creates an iterator over the elements of the array. */ public override operator fun iterator(): kotlin.collections.Iterator<$elementType> = Iterator(storage) - @Suppress("DEPRECATION_ERROR") - private class Iterator(private val array: $storageArrayType) : ${elementType}Iterator() { + private class Iterator(private val array: $storageArrayType) : kotlin.collections.Iterator<${elementType}> { private var index = 0 override fun hasNext() = index < array.size - override fun next$elementType() = if (index < array.size) array[index++].to$elementType() else throw NoSuchElementException(index.toString()) + override fun next() = if (index < array.size) array[index++].to$elementType() else throw NoSuchElementException(index.toString()) } override fun contains(element: $elementType): Boolean { @@ -677,8 +652,7 @@ internal constructor( * @property step the number by which the value is incremented on each step. */ @SinceKotlin("1.3") -@Suppress("DEPRECATION_ERROR") -private class ${elementType}ProgressionIterator(first: $elementType, last: $elementType, step: $stepType) : ${elementType}Iterator() { +private class ${elementType}ProgressionIterator(first: $elementType, last: $elementType, step: $stepType) : Iterator<${elementType}> { private val finalElement = last private var hasNext: Boolean = if (step > 0) first <= last else first >= last private val step = step.to$elementType() // use 2-complement math for negative steps @@ -686,7 +660,7 @@ private class ${elementType}ProgressionIterator(first: $elementType, last: $elem override fun hasNext(): Boolean = hasNext - override fun next$elementType(): $elementType { + override fun next(): $elementType { val value = next if (value == finalElement) { if (!hasNext) throw kotlin.NoSuchElementException() diff --git a/libraries/stdlib/api/js-v1/kotlin.collections.kt b/libraries/stdlib/api/js-v1/kotlin.collections.kt index 38907e90de4..25e4774f391 100644 --- a/libraries/stdlib/api/js-v1/kotlin.collections.kt +++ b/libraries/stdlib/api/js-v1/kotlin.collections.kt @@ -11097,51 +11097,11 @@ public abstract class ShortIterator : kotlin.collections.Iterator public abstract fun nextShort(): kotlin.Short } - +/*∆*/ /*∆*/ public abstract class ShortIterator : kotlin.collections.Iterator { /*∆*/ public constructor ShortIterator() /*∆*/ /*∆*/ public final override operator fun next(): kotlin.Short /*∆*/ /*∆*/ public abstract fun nextShort(): kotlin.Short -/*∆*/ } -/*∆*/ -@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.") -@kotlin.SinceKotlin(version = "1.3") -public abstract class UByteIterator : kotlin.collections.Iterator { - public constructor UByteIterator() - - public final override operator fun next(): kotlin.UByte - - public abstract fun nextUByte(): kotlin.UByte -} - -@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.") -@kotlin.SinceKotlin(version = "1.3") -public abstract class UIntIterator : kotlin.collections.Iterator { - public constructor UIntIterator() - - public final override operator fun next(): kotlin.UInt - - public abstract fun nextUInt(): kotlin.UInt -} - -@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.") -@kotlin.SinceKotlin(version = "1.3") -public abstract class ULongIterator : kotlin.collections.Iterator { - public constructor ULongIterator() - - public final override operator fun next(): kotlin.ULong - - public abstract fun nextULong(): kotlin.ULong -} - -@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.") -@kotlin.SinceKotlin(version = "1.3") -public abstract class UShortIterator : kotlin.collections.Iterator { - public constructor UShortIterator() - - public final override operator fun next(): kotlin.UShort - - public abstract fun nextUShort(): kotlin.UShort -} \ No newline at end of file +/*∆*/ } \ No newline at end of file diff --git a/libraries/stdlib/api/js/kotlin.collections.kt b/libraries/stdlib/api/js/kotlin.collections.kt index 399107f8f1d..e7c942de83c 100644 --- a/libraries/stdlib/api/js/kotlin.collections.kt +++ b/libraries/stdlib/api/js/kotlin.collections.kt @@ -10808,44 +10808,4 @@ public abstract class ShortIterator : kotlin.collections.Iterator public final override operator fun next(): kotlin.Short public abstract fun nextShort(): kotlin.Short -} - -@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.") -@kotlin.SinceKotlin(version = "1.3") -public abstract class UByteIterator : kotlin.collections.Iterator { - public constructor UByteIterator() - - public final override operator fun next(): kotlin.UByte - - public abstract fun nextUByte(): kotlin.UByte -} - -@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.") -@kotlin.SinceKotlin(version = "1.3") -public abstract class UIntIterator : kotlin.collections.Iterator { - public constructor UIntIterator() - - public final override operator fun next(): kotlin.UInt - - public abstract fun nextUInt(): kotlin.UInt -} - -@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.") -@kotlin.SinceKotlin(version = "1.3") -public abstract class ULongIterator : kotlin.collections.Iterator { - public constructor ULongIterator() - - public final override operator fun next(): kotlin.ULong - - public abstract fun nextULong(): kotlin.ULong -} - -@kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "This class is not going to be stabilized and is to be removed soon.") -@kotlin.SinceKotlin(version = "1.3") -public abstract class UShortIterator : kotlin.collections.Iterator { - public constructor UShortIterator() - - public final override operator fun next(): kotlin.UShort - - public abstract fun nextUShort(): kotlin.UShort } \ No newline at end of file diff --git a/libraries/stdlib/unsigned/src/kotlin/UByteArray.kt b/libraries/stdlib/unsigned/src/kotlin/UByteArray.kt index 9bd150f34ec..27e4d686506 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UByteArray.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UByteArray.kt @@ -43,11 +43,10 @@ internal constructor(@PublishedApi internal val storage: ByteArray) : Collection /** Creates an iterator over the elements of the array. */ public override operator fun iterator(): kotlin.collections.Iterator = Iterator(storage) - @Suppress("DEPRECATION_ERROR") - private class Iterator(private val array: ByteArray) : UByteIterator() { + private class Iterator(private val array: ByteArray) : kotlin.collections.Iterator { private var index = 0 override fun hasNext() = index < array.size - override fun nextUByte() = if (index < array.size) array[index++].toUByte() else throw NoSuchElementException(index.toString()) + override fun next() = if (index < array.size) array[index++].toUByte() else throw NoSuchElementException(index.toString()) } override fun contains(element: UByte): Boolean { diff --git a/libraries/stdlib/unsigned/src/kotlin/UIntArray.kt b/libraries/stdlib/unsigned/src/kotlin/UIntArray.kt index 27c0138fd16..8490dea6aa8 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UIntArray.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UIntArray.kt @@ -43,11 +43,10 @@ internal constructor(@PublishedApi internal val storage: IntArray) : Collection< /** Creates an iterator over the elements of the array. */ public override operator fun iterator(): kotlin.collections.Iterator = Iterator(storage) - @Suppress("DEPRECATION_ERROR") - private class Iterator(private val array: IntArray) : UIntIterator() { + private class Iterator(private val array: IntArray) : kotlin.collections.Iterator { private var index = 0 override fun hasNext() = index < array.size - override fun nextUInt() = if (index < array.size) array[index++].toUInt() else throw NoSuchElementException(index.toString()) + override fun next() = if (index < array.size) array[index++].toUInt() else throw NoSuchElementException(index.toString()) } override fun contains(element: UInt): Boolean { diff --git a/libraries/stdlib/unsigned/src/kotlin/UIntRange.kt b/libraries/stdlib/unsigned/src/kotlin/UIntRange.kt index 03c0b97e91f..bacfd7b31fe 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UIntRange.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UIntRange.kt @@ -113,8 +113,7 @@ internal constructor( * @property step the number by which the value is incremented on each step. */ @SinceKotlin("1.3") -@Suppress("DEPRECATION_ERROR") -private class UIntProgressionIterator(first: UInt, last: UInt, step: Int) : UIntIterator() { +private class UIntProgressionIterator(first: UInt, last: UInt, step: Int) : Iterator { private val finalElement = last private var hasNext: Boolean = if (step > 0) first <= last else first >= last private val step = step.toUInt() // use 2-complement math for negative steps @@ -122,7 +121,7 @@ private class UIntProgressionIterator(first: UInt, last: UInt, step: Int) : UInt override fun hasNext(): Boolean = hasNext - override fun nextUInt(): UInt { + override fun next(): UInt { val value = next if (value == finalElement) { if (!hasNext) throw kotlin.NoSuchElementException() diff --git a/libraries/stdlib/unsigned/src/kotlin/UIterators.kt b/libraries/stdlib/unsigned/src/kotlin/UIterators.kt deleted file mode 100644 index 492665d481d..00000000000 --- a/libraries/stdlib/unsigned/src/kotlin/UIterators.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -// Auto-generated file. DO NOT EDIT! - -package kotlin.collections - -/** An iterator over a sequence of values of type `UByte`. */ -@Deprecated("This class is not going to be stabilized and is to be removed soon.", level = DeprecationLevel.ERROR) -@SinceKotlin("1.3") -public abstract class UByteIterator : Iterator { - final override fun next() = nextUByte() - - /** Returns the next value in the sequence without boxing. */ - public abstract fun nextUByte(): UByte -} - -/** An iterator over a sequence of values of type `UShort`. */ -@Deprecated("This class is not going to be stabilized and is to be removed soon.", level = DeprecationLevel.ERROR) -@SinceKotlin("1.3") -public abstract class UShortIterator : Iterator { - final override fun next() = nextUShort() - - /** Returns the next value in the sequence without boxing. */ - public abstract fun nextUShort(): UShort -} - -/** An iterator over a sequence of values of type `UInt`. */ -@Deprecated("This class is not going to be stabilized and is to be removed soon.", level = DeprecationLevel.ERROR) -@SinceKotlin("1.3") -public abstract class UIntIterator : Iterator { - final override fun next() = nextUInt() - - /** Returns the next value in the sequence without boxing. */ - public abstract fun nextUInt(): UInt -} - -/** An iterator over a sequence of values of type `ULong`. */ -@Deprecated("This class is not going to be stabilized and is to be removed soon.", level = DeprecationLevel.ERROR) -@SinceKotlin("1.3") -public abstract class ULongIterator : Iterator { - final override fun next() = nextULong() - - /** Returns the next value in the sequence without boxing. */ - public abstract fun nextULong(): ULong -} - diff --git a/libraries/stdlib/unsigned/src/kotlin/ULongArray.kt b/libraries/stdlib/unsigned/src/kotlin/ULongArray.kt index af64ba327b0..44430b762ae 100644 --- a/libraries/stdlib/unsigned/src/kotlin/ULongArray.kt +++ b/libraries/stdlib/unsigned/src/kotlin/ULongArray.kt @@ -43,11 +43,10 @@ internal constructor(@PublishedApi internal val storage: LongArray) : Collection /** Creates an iterator over the elements of the array. */ public override operator fun iterator(): kotlin.collections.Iterator = Iterator(storage) - @Suppress("DEPRECATION_ERROR") - private class Iterator(private val array: LongArray) : ULongIterator() { + private class Iterator(private val array: LongArray) : kotlin.collections.Iterator { private var index = 0 override fun hasNext() = index < array.size - override fun nextULong() = if (index < array.size) array[index++].toULong() else throw NoSuchElementException(index.toString()) + override fun next() = if (index < array.size) array[index++].toULong() else throw NoSuchElementException(index.toString()) } override fun contains(element: ULong): Boolean { diff --git a/libraries/stdlib/unsigned/src/kotlin/ULongRange.kt b/libraries/stdlib/unsigned/src/kotlin/ULongRange.kt index d8188ef66d9..794ef069503 100644 --- a/libraries/stdlib/unsigned/src/kotlin/ULongRange.kt +++ b/libraries/stdlib/unsigned/src/kotlin/ULongRange.kt @@ -113,8 +113,7 @@ internal constructor( * @property step the number by which the value is incremented on each step. */ @SinceKotlin("1.3") -@Suppress("DEPRECATION_ERROR") -private class ULongProgressionIterator(first: ULong, last: ULong, step: Long) : ULongIterator() { +private class ULongProgressionIterator(first: ULong, last: ULong, step: Long) : Iterator { private val finalElement = last private var hasNext: Boolean = if (step > 0) first <= last else first >= last private val step = step.toULong() // use 2-complement math for negative steps @@ -122,7 +121,7 @@ private class ULongProgressionIterator(first: ULong, last: ULong, step: Long) : override fun hasNext(): Boolean = hasNext - override fun nextULong(): ULong { + override fun next(): ULong { val value = next if (value == finalElement) { if (!hasNext) throw kotlin.NoSuchElementException() diff --git a/libraries/stdlib/unsigned/src/kotlin/UShortArray.kt b/libraries/stdlib/unsigned/src/kotlin/UShortArray.kt index 47d55e6de05..4e27f43037e 100644 --- a/libraries/stdlib/unsigned/src/kotlin/UShortArray.kt +++ b/libraries/stdlib/unsigned/src/kotlin/UShortArray.kt @@ -43,11 +43,10 @@ internal constructor(@PublishedApi internal val storage: ShortArray) : Collectio /** Creates an iterator over the elements of the array. */ public override operator fun iterator(): kotlin.collections.Iterator = Iterator(storage) - @Suppress("DEPRECATION_ERROR") - private class Iterator(private val array: ShortArray) : UShortIterator() { + private class Iterator(private val array: ShortArray) : kotlin.collections.Iterator { private var index = 0 override fun hasNext() = index < array.size - override fun nextUShort() = if (index < array.size) array[index++].toUShort() else throw NoSuchElementException(index.toString()) + override fun next() = if (index < array.size) array[index++].toUShort() else throw NoSuchElementException(index.toString()) } override fun contains(element: UShort): Boolean { diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt index 7a5f6c73b88..2621dc161cd 100644 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt +++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt @@ -2627,14 +2627,6 @@ public abstract class kotlin/collections/ShortIterator : java/util/Iterator, kot public fun remove ()V } -public abstract class kotlin/collections/UByteIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker { - public fun ()V - public synthetic fun next ()Ljava/lang/Object; - public final fun next-w2LRezQ ()B - public abstract fun nextUByte-w2LRezQ ()B - public fun remove ()V -} - public final class kotlin/collections/UCollectionsKt { public static final fun sumOfUByte (Ljava/lang/Iterable;)I public static final fun sumOfUInt (Ljava/lang/Iterable;)I @@ -2646,30 +2638,6 @@ public final class kotlin/collections/UCollectionsKt { public static final fun toUShortArray (Ljava/util/Collection;)[S } -public abstract class kotlin/collections/UIntIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker { - public fun ()V - public synthetic fun next ()Ljava/lang/Object; - public final fun next-pVg5ArA ()I - public abstract fun nextUInt-pVg5ArA ()I - public fun remove ()V -} - -public abstract class kotlin/collections/ULongIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker { - public fun ()V - public synthetic fun next ()Ljava/lang/Object; - public final fun next-s-VKNKU ()J - public abstract fun nextULong-s-VKNKU ()J - public fun remove ()V -} - -public abstract class kotlin/collections/UShortIterator : java/util/Iterator, kotlin/jvm/internal/markers/KMappedMarker { - public fun ()V - public synthetic fun next ()Ljava/lang/Object; - public final fun next-Mh2AYeg ()S - public abstract fun nextUShort-Mh2AYeg ()S - public fun remove ()V -} - public final class kotlin/collections/unsigned/UArraysKt { public static final fun asList--ajY-9A ([I)Ljava/util/List; public static final fun asList-GBYM_sE ([B)Ljava/util/List;