Delete Hashable, pull up its members to Any
Extensions on nullable types remain in Library.kt #KT-1741 Obsolete #KT-2805 Obsolete #KT-1365 Fixed #KT-4517 In Progress
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
package jet
|
||||
|
||||
public open class Any() {}
|
||||
public open class Any {
|
||||
public open fun equals(other: Any?): Boolean
|
||||
|
||||
public open fun hashCode(): Int
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package jet
|
||||
|
||||
public class Char private () : Hashable, Comparable<Char> {
|
||||
public class Char private () : Comparable<Char> {
|
||||
public fun compareTo(other : Double) : Int
|
||||
public fun compareTo(other : Float) : Int
|
||||
public fun compareTo(other : Long) : Int
|
||||
@@ -63,7 +63,4 @@ public class Char private () : Hashable, Comparable<Char> {
|
||||
public fun toChar() : Char
|
||||
public fun toShort() : Short
|
||||
public fun toByte() : Byte
|
||||
|
||||
public override fun hashCode() : Int
|
||||
public override fun equals(other : Any?) : Boolean
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public trait MutableIterable<out T> : Iterable<T> {
|
||||
override fun iterator() : MutableIterator<T>
|
||||
}
|
||||
|
||||
public trait Collection<out E> : Iterable<E>, Hashable {
|
||||
public trait Collection<out E> : Iterable<E> {
|
||||
// Query Operations
|
||||
public fun size() : Int
|
||||
public fun isEmpty() : Boolean
|
||||
@@ -123,7 +123,7 @@ public trait Map<K, out V> {
|
||||
public fun values() : Collection<V>
|
||||
public fun entrySet() : Set<Map.Entry<K, V>>
|
||||
|
||||
public trait Entry<out K, out V> : Hashable {
|
||||
public trait Entry<out K, out V> {
|
||||
public fun getKey() : K
|
||||
public fun getValue() : V
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public trait MutableMap<K, V> : Map<K, V> {
|
||||
override fun values() : MutableCollection<V>
|
||||
override fun entrySet() : MutableSet<MutableMap.MutableEntry<K, V>>
|
||||
|
||||
public trait MutableEntry<K,V> : Map.Entry<K, V>, Hashable {
|
||||
public trait MutableEntry<K,V> : Map.Entry<K, V> {
|
||||
public fun setValue(value : V) : V
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,27 +4,21 @@ public trait Annotation
|
||||
|
||||
public annotation class volatile
|
||||
|
||||
public fun <R> synchronized(lock: Any, block : () -> R) : R
|
||||
public fun <R> synchronized(lock: Any, block: () -> R): R
|
||||
|
||||
public fun Any?.identityEquals(other : Any?) : Boolean // = this === other
|
||||
public fun Any?.identityEquals(other: Any?): Boolean // = this === other
|
||||
|
||||
// Can't write a body due to a bootstrapping problem (see JET-74)
|
||||
public fun Any?.equals(other : Any?) : Boolean// = this === other
|
||||
public fun Any?.equals(other: Any?): Boolean
|
||||
|
||||
// Returns "null" for null
|
||||
public fun Any?.toString() : String// = this === other
|
||||
public fun Any?.toString(): String
|
||||
|
||||
public fun String?.plus(other: Any?) : String
|
||||
public fun String?.plus(other: Any?): String
|
||||
|
||||
public trait Comparable<in T> {
|
||||
public fun compareTo(other : T) : Int
|
||||
}
|
||||
|
||||
public trait Hashable {
|
||||
public fun hashCode() : Int
|
||||
public fun equals(other : Any?) : Boolean
|
||||
}
|
||||
|
||||
public class Boolean private () : Comparable<Boolean> {
|
||||
public fun not() : Boolean
|
||||
|
||||
@@ -35,8 +29,6 @@ public class Boolean private () : Comparable<Boolean> {
|
||||
public fun xor(other : Boolean) : Boolean
|
||||
|
||||
public override fun compareTo(other : Boolean) : Int
|
||||
|
||||
public fun equals(other : Any?) : Boolean
|
||||
}
|
||||
|
||||
public trait CharSequence {
|
||||
@@ -50,8 +42,6 @@ public trait CharSequence {
|
||||
public class String() : Comparable<String>, CharSequence {
|
||||
public fun plus(other : Any?) : String
|
||||
|
||||
public fun equals(other : Any?) : Boolean
|
||||
|
||||
public override fun compareTo(that : String) : Int
|
||||
public override fun get(index : Int) : Char
|
||||
public override fun toString() : String
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package jet
|
||||
|
||||
public abstract class Number : Hashable {
|
||||
public abstract class Number {
|
||||
public abstract fun toDouble() : Double
|
||||
public abstract fun toFloat() : Float
|
||||
public abstract fun toLong() : Long
|
||||
@@ -8,13 +8,6 @@ public abstract class Number : Hashable {
|
||||
public abstract fun toChar() : Char
|
||||
public abstract fun toShort() : Short
|
||||
public abstract fun toByte() : Byte
|
||||
// fun equals(other : Double) : Boolean
|
||||
// fun equals(other : Float) : Boolean
|
||||
// fun equals(other : Long) : Boolean
|
||||
// fun equals(other : Byte) : Boolean
|
||||
// fun equals(other : Int) : Boolean
|
||||
// fun equals(other : Short) : Boolean
|
||||
// fun equals(other : Char) : Boolean
|
||||
}
|
||||
|
||||
public class Double private () : Number, Comparable<Double> {
|
||||
@@ -85,9 +78,6 @@ public class Double private () : Number, Comparable<Double> {
|
||||
public override fun toChar() : Char
|
||||
public override fun toShort() : Short
|
||||
public override fun toByte() : Byte
|
||||
|
||||
public override fun hashCode() : Int
|
||||
public override fun equals(other : Any?) : Boolean
|
||||
}
|
||||
|
||||
public class Float private () : Number, Comparable<Float> {
|
||||
@@ -159,9 +149,6 @@ public class Float private () : Number, Comparable<Float> {
|
||||
public override fun toChar() : Char
|
||||
public override fun toShort() : Short
|
||||
public override fun toByte() : Byte
|
||||
|
||||
public override fun hashCode() : Int
|
||||
public override fun equals(other : Any?) : Boolean
|
||||
}
|
||||
|
||||
public class Long private () : Number, Comparable<Long> {
|
||||
@@ -241,9 +228,6 @@ public class Long private () : Number, Comparable<Long> {
|
||||
public override fun toChar() : Char
|
||||
public override fun toShort() : Short
|
||||
public override fun toByte() : Byte
|
||||
|
||||
public override fun hashCode() : Int
|
||||
public override fun equals(other : Any?) : Boolean
|
||||
}
|
||||
|
||||
public class Int private () : Number, Comparable<Int> {
|
||||
@@ -323,9 +307,6 @@ public class Int private () : Number, Comparable<Int> {
|
||||
public override fun toChar() : Char
|
||||
public override fun toShort() : Short
|
||||
public override fun toByte() : Byte
|
||||
|
||||
public override fun hashCode() : Int
|
||||
public override fun equals(other : Any?) : Boolean
|
||||
}
|
||||
|
||||
public class Short private () : Number, Comparable<Short> {
|
||||
@@ -397,9 +378,6 @@ public class Short private () : Number, Comparable<Short> {
|
||||
public override fun toChar() : Char
|
||||
public override fun toShort() : Short
|
||||
public override fun toByte() : Byte
|
||||
|
||||
public override fun hashCode() : Int
|
||||
public override fun equals(other : Any?) : Boolean
|
||||
}
|
||||
|
||||
public class Byte private () : Number, Comparable<Byte> {
|
||||
@@ -471,7 +449,4 @@ public class Byte private () : Number, Comparable<Byte> {
|
||||
public override fun toChar() : Char
|
||||
public override fun toShort() : Short
|
||||
public override fun toByte() : Byte
|
||||
|
||||
public override fun hashCode() : Int
|
||||
public override fun equals(other : Any?) : Boolean
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ public class ByteProgression(
|
||||
|
||||
override fun iterator(): ByteIterator = ByteProgressionIterator(start, end, increment)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is ByteProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
fun hashCode(): Int = 31 * (31 * start.toInt() + end) + increment
|
||||
override fun hashCode(): Int = 31 * (31 * start.toInt() + end) + increment
|
||||
|
||||
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
|
||||
}
|
||||
@@ -48,10 +48,10 @@ public class CharProgression(
|
||||
|
||||
override fun iterator(): CharIterator = CharProgressionIterator(start, end, increment)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is CharProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
fun hashCode(): Int = 31 * (31 * start.toInt() + end) + increment
|
||||
override fun hashCode(): Int = 31 * (31 * start.toInt() + end) + increment
|
||||
|
||||
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
|
||||
}
|
||||
@@ -67,10 +67,10 @@ public class ShortProgression(
|
||||
|
||||
override fun iterator(): ShortIterator = ShortProgressionIterator(start, end, increment)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is ShortProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
fun hashCode(): Int = 31 * (31 * start.toInt() + end) + increment
|
||||
override fun hashCode(): Int = 31 * (31 * start.toInt() + end) + increment
|
||||
|
||||
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
|
||||
}
|
||||
@@ -86,10 +86,10 @@ public class IntProgression(
|
||||
|
||||
override fun iterator(): IntIterator = IntProgressionIterator(start, end, increment)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is IntProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
fun hashCode(): Int = 31 * (31 * start + end) + increment
|
||||
override fun hashCode(): Int = 31 * (31 * start + end) + increment
|
||||
|
||||
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
|
||||
}
|
||||
@@ -105,10 +105,10 @@ public class LongProgression(
|
||||
|
||||
override fun iterator(): LongIterator = LongProgressionIterator(start, end, increment)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is LongProgression && start == other.start && end == other.end && increment == other.increment
|
||||
|
||||
fun hashCode(): Int = (31 * (31 * (start xor (start ushr 32)) + (end xor (end ushr 32))) + (increment xor (increment ushr 32))).toInt()
|
||||
override fun hashCode(): Int = (31 * (31 * (start xor (start ushr 32)) + (end xor (end ushr 32))) + (increment xor (increment ushr 32))).toInt()
|
||||
|
||||
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
|
||||
}
|
||||
@@ -125,10 +125,10 @@ public class FloatProgression(
|
||||
|
||||
override fun iterator(): FloatIterator = FloatProgressionIterator(start, end, increment)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is FloatProgression && java.lang.Float.compare(start, other.start) == 0 && java.lang.Float.compare(end, other.end) == 0 && java.lang.Float.compare(increment, other.increment) == 0
|
||||
|
||||
fun hashCode(): Int = 31 * (31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(end)) + java.lang.Float.floatToIntBits(increment)
|
||||
override fun hashCode(): Int = 31 * (31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(end)) + java.lang.Float.floatToIntBits(increment)
|
||||
|
||||
fun toString(): String = if (increment > 0) "$start..$end step $increment" else "$start downTo $end step ${-increment}"
|
||||
}
|
||||
@@ -145,10 +145,10 @@ public class DoubleProgression(
|
||||
|
||||
override fun iterator(): DoubleIterator = DoubleProgressionIterator(start, end, increment)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is DoubleProgression && java.lang.Double.compare(start, other.start) == 0 && java.lang.Double.compare(end, other.end) == 0 && java.lang.Double.compare(increment, other.increment) == 0
|
||||
|
||||
fun hashCode(): Int {
|
||||
override fun hashCode(): Int {
|
||||
var temp = java.lang.Double.doubleToLongBits(start)
|
||||
var result = (temp xor (temp ushr 32))
|
||||
temp = java.lang.Double.doubleToLongBits(end)
|
||||
|
||||
@@ -26,10 +26,10 @@ public class ByteRange(public override val start: Byte, public override val end:
|
||||
|
||||
override fun iterator(): ByteIterator = ByteProgressionIterator(start, end, 1)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is ByteRange && start == other.start && end == other.end
|
||||
|
||||
fun hashCode(): Int = 31 * start.toInt() + end
|
||||
override fun hashCode(): Int = 31 * start.toInt() + end
|
||||
|
||||
class object {
|
||||
public val EMPTY: ByteRange = ByteRange(1, 0)
|
||||
@@ -44,10 +44,10 @@ public class CharRange(public override val start: Char, public override val end:
|
||||
|
||||
override fun iterator(): CharIterator = CharProgressionIterator(start, end, 1)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is CharRange && start == other.start && end == other.end
|
||||
|
||||
fun hashCode(): Int = 31 * start.toInt() + end
|
||||
override fun hashCode(): Int = 31 * start.toInt() + end
|
||||
|
||||
class object {
|
||||
public val EMPTY: CharRange = CharRange(1.toChar(), 0.toChar())
|
||||
@@ -62,10 +62,10 @@ public class ShortRange(public override val start: Short, public override val en
|
||||
|
||||
override fun iterator(): ShortIterator = ShortProgressionIterator(start, end, 1)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is ShortRange && start == other.start && end == other.end
|
||||
|
||||
fun hashCode(): Int = 31 * start.toInt() + end
|
||||
override fun hashCode(): Int = 31 * start.toInt() + end
|
||||
|
||||
class object {
|
||||
public val EMPTY: ShortRange = ShortRange(1, 0)
|
||||
@@ -80,10 +80,10 @@ public class IntRange(public override val start: Int, public override val end: I
|
||||
|
||||
override fun iterator(): IntIterator = IntProgressionIterator(start, end, 1)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is IntRange && start == other.start && end == other.end
|
||||
|
||||
fun hashCode(): Int = 31 * start + end
|
||||
override fun hashCode(): Int = 31 * start + end
|
||||
|
||||
class object {
|
||||
public val EMPTY: IntRange = IntRange(1, 0)
|
||||
@@ -98,10 +98,10 @@ public class LongRange(public override val start: Long, public override val end:
|
||||
|
||||
override fun iterator(): LongIterator = LongProgressionIterator(start, end, 1)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is LongRange && start == other.start && end == other.end
|
||||
|
||||
fun hashCode(): Int = (31 * (start xor (start ushr 32)) + (end xor (end ushr 32))).toInt()
|
||||
override fun hashCode(): Int = (31 * (start xor (start ushr 32)) + (end xor (end ushr 32))).toInt()
|
||||
|
||||
class object {
|
||||
public val EMPTY: LongRange = LongRange(1, 0)
|
||||
@@ -116,10 +116,10 @@ public class FloatRange(public override val start: Float, public override val en
|
||||
|
||||
override fun iterator(): FloatIterator = FloatProgressionIterator(start, end, 1.0f)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is FloatRange && java.lang.Float.compare(start, other.start) == 0 && java.lang.Float.compare(end, other.end) == 0
|
||||
|
||||
fun hashCode(): Int = 31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(end)
|
||||
override fun hashCode(): Int = 31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(end)
|
||||
|
||||
class object {
|
||||
public val EMPTY: FloatRange = FloatRange(1.0f, 0.0f)
|
||||
@@ -134,10 +134,10 @@ public class DoubleRange(public override val start: Double, public override val
|
||||
|
||||
override fun iterator(): DoubleIterator = DoubleProgressionIterator(start, end, 1.0)
|
||||
|
||||
fun equals(other: Any?): Boolean =
|
||||
override fun equals(other: Any?): Boolean =
|
||||
other is DoubleRange && java.lang.Double.compare(start, other.start) == 0 && java.lang.Double.compare(end, other.end) == 0
|
||||
|
||||
fun hashCode(): Int {
|
||||
override fun hashCode(): Int {
|
||||
var temp = java.lang.Double.doubleToLongBits(start)
|
||||
val result = (temp xor (temp ushr 32))
|
||||
temp = java.lang.Double.doubleToLongBits(end)
|
||||
|
||||
-1
@@ -43,7 +43,6 @@ public abstract class JavaToKotlinClassMapBuilder {
|
||||
register(Enum.class, kotlinBuiltIns.getEnum());
|
||||
register(Annotation.class, kotlinBuiltIns.getAnnotation());
|
||||
register(Deprecated.class, kotlinBuiltIns.getDeprecatedAnnotation(), Direction.JAVA_TO_KOTLIN);
|
||||
register(Object.class, kotlinBuiltIns.getHashable(), Direction.KOTLIN_TO_JAVA);
|
||||
register(Void.class, kotlinBuiltIns.getNothing(), Direction.KOTLIN_TO_JAVA);
|
||||
|
||||
register(Iterable.class, kotlinBuiltIns.getIterable(), kotlinBuiltIns.getMutableIterable());
|
||||
|
||||
@@ -51,12 +51,11 @@ public class SubstitutionUtils {
|
||||
For each supertype of a given type, we map type parameters to type arguments.
|
||||
|
||||
For instance, we have the following class hierarchy:
|
||||
trait Hashable
|
||||
trait Iterable<out T>
|
||||
trait Collection<out E>: Iterable<E>, Hashable
|
||||
trait Collection<out E>: Iterable<E>
|
||||
trait MyFooCollection<F>: Collection<Foo<F>>
|
||||
|
||||
For MyFunCollection<out CharSequence>, the following multimap will be returned:
|
||||
For MyFooCollection<out CharSequence>, the following multimap will be returned:
|
||||
T declared in Iterable -> Foo<out CharSequence>
|
||||
E declared in Collection -> Foo<out CharSequence>
|
||||
F declared in MyFooCollection -> out CharSequence
|
||||
|
||||
@@ -307,11 +307,6 @@ public class KotlinBuiltIns {
|
||||
return getBuiltInClassByName("Number");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getHashable() {
|
||||
return getBuiltInClassByName("Hashable");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassDescriptor getUnit() {
|
||||
return getBuiltInClassByName("Unit");
|
||||
@@ -514,7 +509,6 @@ public class KotlinBuiltIns {
|
||||
getString(),
|
||||
getCharSequence(),
|
||||
getThrowable(),
|
||||
getBuiltInClassByName("Hashable"),
|
||||
|
||||
getIterator(),
|
||||
getIterable(),
|
||||
|
||||
Reference in New Issue
Block a user