Prohibit step size of min value, as it doesn't have a negated counterpart
#KT-17176
This commit is contained in:
committed by
Ilya Gorbunov
parent
c6c3b05d02
commit
bdf623f711
@@ -35,7 +35,13 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
LONG -> "0L"
|
||||
else -> "0"
|
||||
}
|
||||
val checkZero = "if (step == $zero) throw kotlin.IllegalArgumentException(\"Step must be non-zero\")"
|
||||
val checkZero = """if (step == $zero) throw kotlin.IllegalArgumentException("Step must be non-zero")"""
|
||||
|
||||
val minValue = when (kind) {
|
||||
LONG -> "Long.MIN_VALUE"
|
||||
else -> "Int.MIN_VALUE"
|
||||
}
|
||||
val checkMin = """else if (step == $minValue) throw kotlin.IllegalArgumentException("Step must have an inverse")"""
|
||||
|
||||
val hashCode = "=\n" + when (kind) {
|
||||
CHAR ->
|
||||
@@ -60,6 +66,7 @@ public open class $progression
|
||||
) : Iterable<$t> {
|
||||
init {
|
||||
$checkZero
|
||||
$checkMin
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user