Deprecate Byte and Short ranges and progressions.

Inherit TRange from TProgression.
Remove InclusiveRangeProgression and leave generic Progression deprecated.
This commit is contained in:
Ilya Gorbunov
2015-10-29 16:47:18 +03:00
parent e699ce9e95
commit 6ac0ac01b3
5 changed files with 103 additions and 115 deletions
+1 -32
View File
@@ -22,7 +22,7 @@ package kotlin
* bytecode generation for it. Progressions with a step of -1 can be created through the * bytecode generation for it. Progressions with a step of -1 can be created through the
* `downTo` method on classes representing primitive types. * `downTo` method on classes representing primitive types.
*/ */
@Deprecated("This progression has unclear inclusiveness of end value. Use InclusiveRangeProgression instead.", ReplaceWith("InclusiveRangeProgression<N>")) @Deprecated("This generic progression interface is not of much use and will be removed soon. Use concrete progression implementation instead: IntProgression, LongProgression or CharProgression.")
public interface Progression<out N : Any> : Iterable<N> { public interface Progression<out N : Any> : Iterable<N> {
/** /**
* The start value of the progression. * The start value of the progression.
@@ -39,34 +39,3 @@ public interface Progression<out N : Any> : Iterable<N> {
*/ */
public val increment: Number public val increment: Number
} }
/**
* Represents an arithmetical progression of numbers or characters with a given start value, end value and step.
* This class is intended to be used in 'for' loops, and the JVM backend suggests efficient
* bytecode generation for it. Progressions with a step of -1 can be created through the
* `downTo` method on classes representing primitive types.
*/
public interface InclusiveRangeProgression<out N : Any> : Progression<N> {
/**
* The start value of the progression.
*/
public override val start: N
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
public override val end: N get() = endInclusive
/**
* The end value of the progression (inclusive).
*/
public val endInclusive: N
/**
* The step of the progression.
*/
public override val increment: Number
}
+74 -30
View File
@@ -18,22 +18,29 @@
package kotlin package kotlin
@Deprecated("Use IntProgression instead.", ReplaceWith("IntProgression"), level = DeprecationLevel.WARNING)
/** /**
* A progression of values of type `Byte`. * A progression of values of type `Byte`.
*/ */
public class ByteProgression( public open class ByteProgression(
override val start: Byte, override val start: Byte,
override val endInclusive: Byte, val endInclusive: Byte,
override val increment: Int override val increment: Int
) : InclusiveRangeProgression<Byte> { ) : Progression<Byte>, Iterable<Byte> {
init { init {
if (increment == 0) throw IllegalArgumentException("Increment must be non-zero") if (increment == 0) throw IllegalArgumentException("Increment must be non-zero")
} }
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
public override val end: Byte get() = endInclusive
override fun iterator(): ByteIterator = ByteProgressionIterator(start, endInclusive, increment) override fun iterator(): ByteIterator = ByteProgressionIterator(start, endInclusive, increment)
/** Checks if the progression is empty. */ /** Checks if the progression is empty. */
public fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is ByteProgression && (isEmpty() && other.isEmpty() || other is ByteProgression && (isEmpty() && other.isEmpty() ||
@@ -48,19 +55,25 @@ public class ByteProgression(
/** /**
* A progression of values of type `Char`. * A progression of values of type `Char`.
*/ */
public class CharProgression( public open class CharProgression(
override val start: Char, override val start: Char,
override val endInclusive: Char, val endInclusive: Char,
override val increment: Int override val increment: Int
) : InclusiveRangeProgression<Char> { ) : Progression<Char>, Iterable<Char> {
init { init {
if (increment == 0) throw IllegalArgumentException("Increment must be non-zero") if (increment == 0) throw IllegalArgumentException("Increment must be non-zero")
} }
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
public override val end: Char get() = endInclusive
override fun iterator(): CharIterator = CharProgressionIterator(start, endInclusive, increment) override fun iterator(): CharIterator = CharProgressionIterator(start, endInclusive, increment)
/** Checks if the progression is empty. */ /** Checks if the progression is empty. */
public fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is CharProgression && (isEmpty() && other.isEmpty() || other is CharProgression && (isEmpty() && other.isEmpty() ||
@@ -72,22 +85,29 @@ public class CharProgression(
override fun toString(): String = if (increment > 0) "$start..$endInclusive step $increment" else "$start downTo $endInclusive step ${-increment}" override fun toString(): String = if (increment > 0) "$start..$endInclusive step $increment" else "$start downTo $endInclusive step ${-increment}"
} }
@Deprecated("Use IntProgression instead.", ReplaceWith("IntProgression"), level = DeprecationLevel.WARNING)
/** /**
* A progression of values of type `Short`. * A progression of values of type `Short`.
*/ */
public class ShortProgression( public open class ShortProgression(
override val start: Short, override val start: Short,
override val endInclusive: Short, val endInclusive: Short,
override val increment: Int override val increment: Int
) : InclusiveRangeProgression<Short> { ) : Progression<Short>, Iterable<Short> {
init { init {
if (increment == 0) throw IllegalArgumentException("Increment must be non-zero") if (increment == 0) throw IllegalArgumentException("Increment must be non-zero")
} }
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
public override val end: Short get() = endInclusive
override fun iterator(): ShortIterator = ShortProgressionIterator(start, endInclusive, increment) override fun iterator(): ShortIterator = ShortProgressionIterator(start, endInclusive, increment)
/** Checks if the progression is empty. */ /** Checks if the progression is empty. */
public fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is ShortProgression && (isEmpty() && other.isEmpty() || other is ShortProgression && (isEmpty() && other.isEmpty() ||
@@ -102,19 +122,25 @@ public class ShortProgression(
/** /**
* A progression of values of type `Int`. * A progression of values of type `Int`.
*/ */
public class IntProgression( public open class IntProgression(
override val start: Int, override val start: Int,
override val endInclusive: Int, val endInclusive: Int,
override val increment: Int override val increment: Int
) : InclusiveRangeProgression<Int> { ) : Progression<Int>, Iterable<Int> {
init { init {
if (increment == 0) throw IllegalArgumentException("Increment must be non-zero") if (increment == 0) throw IllegalArgumentException("Increment must be non-zero")
} }
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
public override val end: Int get() = endInclusive
override fun iterator(): IntIterator = IntProgressionIterator(start, endInclusive, increment) override fun iterator(): IntIterator = IntProgressionIterator(start, endInclusive, increment)
/** Checks if the progression is empty. */ /** Checks if the progression is empty. */
public fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is IntProgression && (isEmpty() && other.isEmpty() || other is IntProgression && (isEmpty() && other.isEmpty() ||
@@ -129,19 +155,25 @@ public class IntProgression(
/** /**
* A progression of values of type `Long`. * A progression of values of type `Long`.
*/ */
public class LongProgression( public open class LongProgression(
override val start: Long, override val start: Long,
override val endInclusive: Long, val endInclusive: Long,
override val increment: Long override val increment: Long
) : InclusiveRangeProgression<Long> { ) : Progression<Long>, Iterable<Long> {
init { init {
if (increment == 0L) throw IllegalArgumentException("Increment must be non-zero") if (increment == 0L) throw IllegalArgumentException("Increment must be non-zero")
} }
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
public override val end: Long get() = endInclusive
override fun iterator(): LongIterator = LongProgressionIterator(start, endInclusive, increment) override fun iterator(): LongIterator = LongProgressionIterator(start, endInclusive, increment)
/** Checks if the progression is empty. */ /** Checks if the progression is empty. */
public fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is LongProgression && (isEmpty() && other.isEmpty() || other is LongProgression && (isEmpty() && other.isEmpty() ||
@@ -153,25 +185,31 @@ public class LongProgression(
override fun toString(): String = if (increment > 0) "$start..$endInclusive step $increment" else "$start downTo $endInclusive step ${-increment}" override fun toString(): String = if (increment > 0) "$start..$endInclusive step $increment" else "$start downTo $endInclusive step ${-increment}"
} }
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING) @Deprecated("This progression implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)
@Suppress("DEPRECATION_ERROR") @Suppress("DEPRECATION_ERROR")
/** /**
* A progression of values of type `Float`. * A progression of values of type `Float`.
*/ */
public class FloatProgression( public open class FloatProgression(
override val start: Float, override val start: Float,
override val endInclusive: Float, val endInclusive: Float,
override val increment: Float override val increment: Float
) : InclusiveRangeProgression<Float> { ) : Progression<Float>, Iterable<Float> {
init { init {
if (java.lang.Float.isNaN(increment)) throw IllegalArgumentException("Increment must be not NaN") if (java.lang.Float.isNaN(increment)) throw IllegalArgumentException("Increment must be not NaN")
if (increment == 0.0f) throw IllegalArgumentException("Increment must be non-zero") if (increment == 0.0f) throw IllegalArgumentException("Increment must be non-zero")
} }
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
public override val end: Float get() = endInclusive
override fun iterator(): FloatIterator = FloatProgressionIterator(start, endInclusive, increment) override fun iterator(): FloatIterator = FloatProgressionIterator(start, endInclusive, increment)
/** Checks if the progression is empty. */ /** Checks if the progression is empty. */
public fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is FloatProgression && (isEmpty() && other.isEmpty() || other is FloatProgression && (isEmpty() && other.isEmpty() ||
@@ -183,25 +221,31 @@ public class FloatProgression(
override fun toString(): String = if (increment > 0) "$start..$endInclusive step $increment" else "$start downTo $endInclusive step ${-increment}" override fun toString(): String = if (increment > 0) "$start..$endInclusive step $increment" else "$start downTo $endInclusive step ${-increment}"
} }
@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING) @Deprecated("This progression implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)
@Suppress("DEPRECATION_ERROR") @Suppress("DEPRECATION_ERROR")
/** /**
* A progression of values of type `Double`. * A progression of values of type `Double`.
*/ */
public class DoubleProgression( public open class DoubleProgression(
override val start: Double, override val start: Double,
override val endInclusive: Double, val endInclusive: Double,
override val increment: Double override val increment: Double
) : InclusiveRangeProgression<Double> { ) : Progression<Double>, Iterable<Double> {
init { init {
if (java.lang.Double.isNaN(increment)) throw IllegalArgumentException("Increment must be not NaN") if (java.lang.Double.isNaN(increment)) throw IllegalArgumentException("Increment must be not NaN")
if (increment == 0.0) throw IllegalArgumentException("Increment must be non-zero") if (increment == 0.0) throw IllegalArgumentException("Increment must be non-zero")
} }
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
public override val end: Double get() = endInclusive
override fun iterator(): DoubleIterator = DoubleProgressionIterator(start, endInclusive, increment) override fun iterator(): DoubleIterator = DoubleProgressionIterator(start, endInclusive, increment)
/** Checks if the progression is empty. */ /** Checks if the progression is empty. */
public fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is DoubleProgression && (isEmpty() && other.isEmpty() || other is DoubleProgression && (isEmpty() && other.isEmpty() ||
+9 -42
View File
@@ -18,20 +18,16 @@
package kotlin package kotlin
@Deprecated("Use IntRange instead.", ReplaceWith("IntRange"), level = DeprecationLevel.WARNING)
/** /**
* A range of values of type `Byte`. * A range of values of type `Byte`.
*/ */
public class ByteRange(override val start: Byte, override val endInclusive: Byte) : InclusiveRange<Byte>, InclusiveRangeProgression<Byte> { public class ByteRange(start: Byte, endInclusive: Byte) : ByteProgression(start, endInclusive, 1), InclusiveRange<Byte> {
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
override val end: Byte get() = endInclusive override val end: Byte get() = endInclusive
override val increment: Int
get() = 1
override fun contains(item: Byte): Boolean = start <= item && item <= endInclusive override fun contains(item: Byte): Boolean = start <= item && item <= endInclusive
override fun iterator(): ByteIterator = ByteProgressionIterator(start, endInclusive, 1)
override fun isEmpty(): Boolean = start > endInclusive override fun isEmpty(): Boolean = start > endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
@@ -52,17 +48,12 @@ public class ByteRange(override val start: Byte, override val endInclusive: Byte
/** /**
* A range of values of type `Char`. * A range of values of type `Char`.
*/ */
public class CharRange(override val start: Char, override val endInclusive: Char) : InclusiveRange<Char>, InclusiveRangeProgression<Char> { public class CharRange(start: Char, endInclusive: Char) : CharProgression(start, endInclusive, 1), InclusiveRange<Char> {
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
override val end: Char get() = endInclusive override val end: Char get() = endInclusive
override val increment: Int
get() = 1
override fun contains(item: Char): Boolean = start <= item && item <= endInclusive override fun contains(item: Char): Boolean = start <= item && item <= endInclusive
override fun iterator(): CharIterator = CharProgressionIterator(start, endInclusive, 1)
override fun isEmpty(): Boolean = start > endInclusive override fun isEmpty(): Boolean = start > endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
@@ -80,20 +71,16 @@ public class CharRange(override val start: Char, override val endInclusive: Char
} }
} }
@Deprecated("Use IntRange instead.", ReplaceWith("IntRange"), level = DeprecationLevel.WARNING)
/** /**
* A range of values of type `Short`. * A range of values of type `Short`.
*/ */
public class ShortRange(override val start: Short, override val endInclusive: Short) : InclusiveRange<Short>, InclusiveRangeProgression<Short> { public class ShortRange(start: Short, endInclusive: Short) : ShortProgression(start, endInclusive, 1), InclusiveRange<Short> {
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
override val end: Short get() = endInclusive override val end: Short get() = endInclusive
override val increment: Int
get() = 1
override fun contains(item: Short): Boolean = start <= item && item <= endInclusive override fun contains(item: Short): Boolean = start <= item && item <= endInclusive
override fun iterator(): ShortIterator = ShortProgressionIterator(start, endInclusive, 1)
override fun isEmpty(): Boolean = start > endInclusive override fun isEmpty(): Boolean = start > endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
@@ -114,17 +101,12 @@ public class ShortRange(override val start: Short, override val endInclusive: Sh
/** /**
* A range of values of type `Int`. * A range of values of type `Int`.
*/ */
public class IntRange(override val start: Int, override val endInclusive: Int) : InclusiveRange<Int>, InclusiveRangeProgression<Int> { public class IntRange(start: Int, endInclusive: Int) : IntProgression(start, endInclusive, 1), InclusiveRange<Int> {
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
override val end: Int get() = endInclusive override val end: Int get() = endInclusive
override val increment: Int
get() = 1
override fun contains(item: Int): Boolean = start <= item && item <= endInclusive override fun contains(item: Int): Boolean = start <= item && item <= endInclusive
override fun iterator(): IntIterator = IntProgressionIterator(start, endInclusive, 1)
override fun isEmpty(): Boolean = start > endInclusive override fun isEmpty(): Boolean = start > endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
@@ -145,17 +127,12 @@ public class IntRange(override val start: Int, override val endInclusive: Int) :
/** /**
* A range of values of type `Long`. * A range of values of type `Long`.
*/ */
public class LongRange(override val start: Long, override val endInclusive: Long) : InclusiveRange<Long>, InclusiveRangeProgression<Long> { public class LongRange(start: Long, endInclusive: Long) : LongProgression(start, endInclusive, 1), InclusiveRange<Long> {
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
override val end: Long get() = endInclusive override val end: Long get() = endInclusive
override val increment: Long
get() = 1
override fun contains(item: Long): Boolean = start <= item && item <= endInclusive override fun contains(item: Long): Boolean = start <= item && item <= endInclusive
override fun iterator(): LongIterator = LongProgressionIterator(start, endInclusive, 1)
override fun isEmpty(): Boolean = start > endInclusive override fun isEmpty(): Boolean = start > endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
@@ -178,17 +155,12 @@ public class LongRange(override val start: Long, override val endInclusive: Long
/** /**
* A range of values of type `Float`. * A range of values of type `Float`.
*/ */
public class FloatRange(override val start: Float, override val endInclusive: Float) : InclusiveRange<Float>, InclusiveRangeProgression<Float> { public class FloatRange(start: Float, endInclusive: Float) : FloatProgression(start, endInclusive, 1.0f), InclusiveRange<Float> {
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
override val end: Float get() = endInclusive override val end: Float get() = endInclusive
override val increment: Float
get() = 1.0f
override fun contains(item: Float): Boolean = start <= item && item <= endInclusive override fun contains(item: Float): Boolean = start <= item && item <= endInclusive
override fun iterator(): FloatIterator = FloatProgressionIterator(start, endInclusive, 1.0f)
override fun isEmpty(): Boolean = start > endInclusive override fun isEmpty(): Boolean = start > endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
@@ -211,17 +183,12 @@ public class FloatRange(override val start: Float, override val endInclusive: Fl
/** /**
* A range of values of type `Double`. * A range of values of type `Double`.
*/ */
public class DoubleRange(override val start: Double, override val endInclusive: Double) : InclusiveRange<Double>, InclusiveRangeProgression<Double> { public class DoubleRange(start: Double, endInclusive: Double) : DoubleProgression(start, endInclusive, 1.0), InclusiveRange<Double> {
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
override val end: Double get() = endInclusive override val end: Double get() = endInclusive
override val increment: Double
get() = 1.0
override fun contains(item: Double): Boolean = start <= item && item <= endInclusive override fun contains(item: Double): Boolean = start <= item && item <= endInclusive
override fun iterator(): DoubleIterator = DoubleProgressionIterator(start, endInclusive, 1.0)
override fun isEmpty(): Boolean = start > endInclusive override fun isEmpty(): Boolean = start > endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
@@ -65,27 +65,37 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
} }
if (kind == FLOAT || kind == DOUBLE) { if (kind == FLOAT || kind == DOUBLE) {
out.println("""@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)""") out.println("""@Deprecated("This progression implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)""")
out.println("""@Suppress("DEPRECATION_ERROR")""") out.println("""@Suppress("DEPRECATION_ERROR")""")
} }
if (kind == SHORT || kind == BYTE) {
out.println("""@Deprecated("Use IntProgression instead.", ReplaceWith("IntProgression"), level = DeprecationLevel.WARNING)""")
}
out.println( out.println(
"""/** """/**
* A progression of values of type `$t`. * A progression of values of type `$t`.
*/ */
public class $progression( public open class $progression(
override val start: $t, override val start: $t,
override val endInclusive: $t, val endInclusive: $t,
override val increment: $incrementType override val increment: $incrementType
) : InclusiveRangeProgression<$t> { ) : Progression<$t>, Iterable<$t> {
init { init {
$constructor $constructor
} }
/**
* The end value of the progression (inclusive).
*/
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
public override val end: $t get() = endInclusive
override fun iterator(): ${t}Iterator = ${t}ProgressionIterator(start, endInclusive, increment) override fun iterator(): ${t}Iterator = ${t}ProgressionIterator(start, endInclusive, increment)
/** Checks if the progression is empty. */ /** Checks if the progression is empty. */
public fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =
other is $progression && (isEmpty() && other.isEmpty() || other is $progression && (isEmpty() && other.isEmpty() ||
@@ -68,22 +68,20 @@ class GenerateRanges(out: PrintWriter) : BuiltInsSourceGenerator(out) {
out.println("""@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)""") out.println("""@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)""")
out.println("""@Suppress("DEPRECATION_ERROR")""") out.println("""@Suppress("DEPRECATION_ERROR")""")
} }
if (kind == SHORT || kind == BYTE) {
out.println("""@Deprecated("Use IntRange instead.", ReplaceWith("IntRange"), level = DeprecationLevel.WARNING)""")
}
out.println( out.println(
"""/** """/**
* A range of values of type `$t`. * A range of values of type `$t`.
*/ */
public class $range(override val start: $t, override val endInclusive: $t) : InclusiveRange<$t>, InclusiveRangeProgression<$t> { public class $range(start: $t, endInclusive: $t) : ${t}Progression(start, endInclusive, $increment), InclusiveRange<$t> {
@Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive"))
override val end: $t get() = endInclusive override val end: $t get() = endInclusive
override val increment: $incrementType
get() = $increment
override fun contains(item: $t): Boolean = start <= item && item <= endInclusive override fun contains(item: $t): Boolean = start <= item && item <= endInclusive
override fun iterator(): ${t}Iterator = ${t}ProgressionIterator(start, endInclusive, $increment)
override fun isEmpty(): Boolean = start > endInclusive override fun isEmpty(): Boolean = start > endInclusive
override fun equals(other: Any?): Boolean = override fun equals(other: Any?): Boolean =