Drop Progression<T> and its deprecated properties: start, end, increment.
Drop deprecated range extensions. Make progression constructors private.
This commit is contained in:
@@ -410,30 +410,6 @@ public fun LongProgression.reversed(): LongProgression {
|
||||
return LongProgression.fromClosedRange(last, first, -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range in reverse direction.
|
||||
*/
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public fun CharRange.reversed(): CharProgression {
|
||||
return CharProgression.fromClosedRange(last, first, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range in reverse direction.
|
||||
*/
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public fun IntRange.reversed(): IntProgression {
|
||||
return IntProgression.fromClosedRange(last, first, -1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range in reverse direction.
|
||||
*/
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public fun LongRange.reversed(): LongProgression {
|
||||
return LongProgression.fromClosedRange(last, first, -1L)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over the same range with the given step.
|
||||
*/
|
||||
@@ -458,33 +434,6 @@ public infix fun LongProgression.step(step: Long): LongProgression {
|
||||
return LongProgression.fromClosedRange(first, last, if (this.step > 0) step else -step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range with given step.
|
||||
*/
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public infix fun CharRange.step(step: Int): CharProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return CharProgression.fromClosedRange(first, last, step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range with given step.
|
||||
*/
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public infix fun IntRange.step(step: Int): IntProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return IntProgression.fromClosedRange(first, last, step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a progression that goes over this range with given step.
|
||||
*/
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public infix fun LongRange.step(step: Long): LongProgression {
|
||||
checkStepIsPositive(step > 0, step)
|
||||
return LongProgression.fromClosedRange(first, last, step)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a range from this value up to but excluding the specified [to] value.
|
||||
*/
|
||||
|
||||
@@ -27,14 +27,6 @@ public fun<T> Enumeration<T>.asSequence(): Sequence<T> = this.iterator().asSeque
|
||||
*/
|
||||
public fun <T> sequenceOf(vararg elements: T): Sequence<T> = if (elements.isEmpty()) emptySequence() else elements.asSequence()
|
||||
|
||||
/**
|
||||
* Creates a sequence that returns all values in the specified [progression].
|
||||
*/
|
||||
@Deprecated("Use progression.asSequence() instead.", ReplaceWith("progression.asSequence()"))
|
||||
public fun <T : Any> sequenceOf(progression: Progression<T>): Sequence<T> = object : Sequence<T> {
|
||||
override fun iterator(): Iterator<T> = progression.iterator()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty sequence.
|
||||
*/
|
||||
|
||||
@@ -223,6 +223,7 @@ public fun String.replaceRange(firstIndex: Int, lastIndex: Int, replacement: Str
|
||||
public fun String.replaceRange(range: IntRange, replacement: String): String
|
||||
= replaceRange(range.start, range.end + 1, replacement)
|
||||
|
||||
private val IntRange.end: Int get() = endInclusive
|
||||
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
public fun String.removePrefix(prefix: String): String = removePrefix(prefix)
|
||||
|
||||
@@ -31,12 +31,6 @@ public open class RangeIterationTestBase {
|
||||
last = sequence.last
|
||||
increment = sequence.step
|
||||
}
|
||||
// TODO: Drop this branch
|
||||
is Progression -> {
|
||||
first = sequence.start
|
||||
last = sequence.end
|
||||
increment = sequence.increment
|
||||
}
|
||||
else -> throw IllegalArgumentException("Unsupported sequence type: $sequence")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@file: Suppress("DEPRECATION_ERROR")
|
||||
package language
|
||||
|
||||
import kotlin.ranges.LongProgression.Companion
|
||||
import java.lang.Double as jDouble
|
||||
import java.lang.Float as jFloat
|
||||
import org.junit.Test as test
|
||||
@@ -26,9 +27,9 @@ public class RangeJVMTest {
|
||||
@test fun illegalProgressionCreation() {
|
||||
fun assertFailsWithIllegalArgument(f: () -> Unit) = assertFailsWith(IllegalArgumentException::class, block = f)
|
||||
// create Progression explicitly with increment = 0
|
||||
assertFailsWithIllegalArgument { IntProgression(0, 5, 0) }
|
||||
assertFailsWithIllegalArgument { LongProgression(0, 5, 0) }
|
||||
assertFailsWithIllegalArgument { CharProgression('a', 'z', 0) }
|
||||
assertFailsWithIllegalArgument { IntProgression.fromClosedRange(0, 5, 0) }
|
||||
assertFailsWithIllegalArgument { LongProgression.fromClosedRange(0, 5, 0) }
|
||||
assertFailsWithIllegalArgument { CharProgression.fromClosedRange('a', 'z', 0) }
|
||||
|
||||
|
||||
assertFailsWithIllegalArgument { 0..5 step 0 }
|
||||
|
||||
Reference in New Issue
Block a user