Java 8 override restrictions: interface can't implement a method of 'Any'
- update Range and related classes
This commit is contained in:
@@ -40,6 +40,4 @@ public interface Range<T : Comparable<T>> {
|
|||||||
* Checks if the range is empty.
|
* Checks if the range is empty.
|
||||||
*/
|
*/
|
||||||
public fun isEmpty(): Boolean = start > end
|
public fun isEmpty(): Boolean = start > end
|
||||||
|
|
||||||
override fun toString(): String = "$start..$end"
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public class ByteRange(override val start: Byte, override val end: Byte) : Range
|
|||||||
override fun hashCode(): Int =
|
override fun hashCode(): Int =
|
||||||
if (isEmpty()) -1 else (31 * start.toInt() + end.toInt())
|
if (isEmpty()) -1 else (31 * start.toInt() + end.toInt())
|
||||||
|
|
||||||
|
override fun toString(): String = "$start..$end"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/** An empty range of values of type Byte. */
|
/** An empty range of values of type Byte. */
|
||||||
public val EMPTY: ByteRange = ByteRange(1, 0)
|
public val EMPTY: ByteRange = ByteRange(1, 0)
|
||||||
@@ -64,6 +66,8 @@ public class CharRange(override val start: Char, override val end: Char) : Range
|
|||||||
override fun hashCode(): Int =
|
override fun hashCode(): Int =
|
||||||
if (isEmpty()) -1 else (31 * start.toInt() + end.toInt())
|
if (isEmpty()) -1 else (31 * start.toInt() + end.toInt())
|
||||||
|
|
||||||
|
override fun toString(): String = "$start..$end"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/** An empty range of values of type Char. */
|
/** An empty range of values of type Char. */
|
||||||
public val EMPTY: CharRange = CharRange(1.toChar(), 0.toChar())
|
public val EMPTY: CharRange = CharRange(1.toChar(), 0.toChar())
|
||||||
@@ -90,6 +94,8 @@ public class ShortRange(override val start: Short, override val end: Short) : Ra
|
|||||||
override fun hashCode(): Int =
|
override fun hashCode(): Int =
|
||||||
if (isEmpty()) -1 else (31 * start.toInt() + end.toInt())
|
if (isEmpty()) -1 else (31 * start.toInt() + end.toInt())
|
||||||
|
|
||||||
|
override fun toString(): String = "$start..$end"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/** An empty range of values of type Short. */
|
/** An empty range of values of type Short. */
|
||||||
public val EMPTY: ShortRange = ShortRange(1, 0)
|
public val EMPTY: ShortRange = ShortRange(1, 0)
|
||||||
@@ -116,6 +122,8 @@ public class IntRange(override val start: Int, override val end: Int) : Range<In
|
|||||||
override fun hashCode(): Int =
|
override fun hashCode(): Int =
|
||||||
if (isEmpty()) -1 else (31 * start + end)
|
if (isEmpty()) -1 else (31 * start + end)
|
||||||
|
|
||||||
|
override fun toString(): String = "$start..$end"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/** An empty range of values of type Int. */
|
/** An empty range of values of type Int. */
|
||||||
public val EMPTY: IntRange = IntRange(1, 0)
|
public val EMPTY: IntRange = IntRange(1, 0)
|
||||||
@@ -142,6 +150,8 @@ public class LongRange(override val start: Long, override val end: Long) : Range
|
|||||||
override fun hashCode(): Int =
|
override fun hashCode(): Int =
|
||||||
if (isEmpty()) -1 else (31 * (start xor (start ushr 32)) + (end xor (end ushr 32))).toInt()
|
if (isEmpty()) -1 else (31 * (start xor (start ushr 32)) + (end xor (end ushr 32))).toInt()
|
||||||
|
|
||||||
|
override fun toString(): String = "$start..$end"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/** An empty range of values of type Long. */
|
/** An empty range of values of type Long. */
|
||||||
public val EMPTY: LongRange = LongRange(1, 0)
|
public val EMPTY: LongRange = LongRange(1, 0)
|
||||||
@@ -168,6 +178,8 @@ public class FloatRange(override val start: Float, override val end: Float) : Ra
|
|||||||
override fun hashCode(): Int =
|
override fun hashCode(): Int =
|
||||||
if (isEmpty()) -1 else (31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(end))
|
if (isEmpty()) -1 else (31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(end))
|
||||||
|
|
||||||
|
override fun toString(): String = "$start..$end"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/** An empty range of values of type Float. */
|
/** An empty range of values of type Float. */
|
||||||
public val EMPTY: FloatRange = FloatRange(1.0f, 0.0f)
|
public val EMPTY: FloatRange = FloatRange(1.0f, 0.0f)
|
||||||
@@ -199,6 +211,8 @@ public class DoubleRange(override val start: Double, override val end: Double) :
|
|||||||
return (31 * result + (temp xor (temp ushr 32))).toInt()
|
return (31 * result + (temp xor (temp ushr 32))).toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = "$start..$end"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/** An empty range of values of type Double. */
|
/** An empty range of values of type Double. */
|
||||||
public val EMPTY: DoubleRange = DoubleRange(1.0, 0.0)
|
public val EMPTY: DoubleRange = DoubleRange(1.0, 0.0)
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ class GenerateRanges(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
|||||||
" }"
|
" }"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val toString = "\"\$start..\$end\""
|
||||||
|
|
||||||
out.println(
|
out.println(
|
||||||
"""/**
|
"""/**
|
||||||
* A range of values of type `$t`.
|
* A range of values of type `$t`.
|
||||||
@@ -82,6 +84,8 @@ public class $range(override val start: $t, override val end: $t) : Range<$t>, P
|
|||||||
|
|
||||||
override fun hashCode(): Int $hashCode
|
override fun hashCode(): Int $hashCode
|
||||||
|
|
||||||
|
override fun toString(): String = $toString
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/** An empty range of values of type $t. */
|
/** An empty range of values of type $t. */
|
||||||
public val EMPTY: $range = $range($emptyBounds)
|
public val EMPTY: $range = $range($emptyBounds)
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public class ComparableRange<T: Comparable<T>> (
|
|||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
return if (isEmpty()) -1 else 31 * start.hashCode() + end.hashCode()
|
return if (isEmpty()) -1 else 31 * start.hashCode() + end.hashCode()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun toString(): String = "$start..$end"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user