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:
Alexander Udalov
2014-02-04 19:54:06 +04:00
parent 9efdd136ba
commit ec30d52978
46 changed files with 210 additions and 416 deletions
@@ -6,12 +6,12 @@ class T4(
val c3: Boolean,
val c4: String
) {
fun equals(o: Any?): Boolean {
if (o !is T4) return false;
return c1 == o.c1 &&
c2 == o.c2 &&
c3 == o.c3 &&
c4 == o.c4
override fun equals(other: Any?): Boolean {
if (other !is T4) return false;
return c1 == other.c1 &&
c2 == other.c2 &&
c3 == other.c3 &&
c4 == other.c4
}
}
@@ -1,11 +1,11 @@
package foo
class Foo(val name: String) {
public fun equals(that: Any?): Boolean {
if (that !is Foo) {
override fun equals(other: Any?): Boolean {
if (other !is Foo) {
return false
}
return this.name == that.name
return this.name == other.name
}
}
@@ -1,11 +1,11 @@
package foo
class Foo(val name: String) {
public fun equals(that: Any?): Boolean {
if (that !is Foo) {
override fun equals(other: Any?): Boolean {
if (other !is Foo) {
return false
}
return this.name == that.name
return this.name == other.name
}
}
@@ -1,11 +1,11 @@
package foo
class Foo(val name: String) {
public fun equals(that: Any?): Boolean {
if (that !is Foo) {
override fun equals(other: Any?): Boolean {
if (other !is Foo) {
return false
}
return this.name == that.name
return this.name == other.name
}
}
@@ -4,15 +4,15 @@ public fun equals(a: Any?): Boolean = true
public fun hashCode(): Int = 0
public fun toString(): String = ""
public class PublicClassWithPublics {
public fun equals(a: Any?): Boolean = this.identityEquals(a)
public fun hashCode(): Int = 0
public class PublicClass {
override fun equals(a: Any?): Boolean = this.identityEquals(a)
override fun hashCode(): Int = 0
public fun toString(): String = "PublicClass"
}
class InternalClassWithPublics {
public fun equals(a: Any?): Boolean = this.identityEquals(a)
public fun hashCode(): Int = 1
internal class InternalClass {
override fun equals(a: Any?): Boolean = this.identityEquals(a)
override fun hashCode(): Int = 1
public fun toString(): String = "InternalClass"
// overloads
@@ -21,9 +21,9 @@ class InternalClassWithPublics {
public fun toString(s: String): String = s
}
private class PrivateClassWithPublics {
public fun equals(a: Any?): Boolean = this.identityEquals(a)
public fun hashCode(): Int = 2
private class PrivateClass {
override fun equals(a: Any?): Boolean = this.identityEquals(a)
override fun hashCode(): Int = 2
public fun toString(): String = "InternalClass"
// overloads
@@ -32,126 +32,6 @@ private class PrivateClassWithPublics {
public fun toString(s: String): String = s
}
public class PublicClassWithProtecteds {
protected fun equals(a: Any?): Boolean = this.identityEquals(a)
protected fun hashCode(): Int = 0
protected fun toString(): String = "public Bar"
val call_equals: ()->Unit = { equals(0) }
val call_hashCode: ()->Unit = { hashCode() }
val call_toString: ()->Unit = { toString() }
}
class InternalClassWithProtecteds {
protected fun equals(a: Any?): Boolean = this.identityEquals(a)
protected fun hashCode(): Int = 1
protected fun toString(): String = "InternalClass"
// overloads
protected fun equals(a: Any?, b: Any?): Boolean = a == b
protected fun hashCode(i: Int): Int = i
protected fun toString(s: String): String = s
val call_equals: ()->Unit = { equals(0) }
val call_hashCode: ()->Unit = { hashCode() }
val call_toString: ()->Unit = { toString() }
val call_equals2: ()->Unit = { equals(0, 1) }
val call_hashCode2: ()->Unit = { hashCode(2) }
val call_toString2: ()->Unit = { toString("3") }
}
private class PrivateClassWithProtecteds {
protected fun equals(a: Any?): Boolean = this.identityEquals(a)
protected fun hashCode(): Int = 2
protected fun toString(): String = "InternalClass"
// overloads
protected fun equals(a: Any?, b: Any?): Boolean = a == b
protected fun hashCode(i: Int): Int = i
protected fun toString(s: String): String = s
val call_equals: ()->Unit = { equals(0) }
val call_hashCode: ()->Unit = { hashCode() }
val call_toString: ()->Unit = { toString() }
val call_equals2: ()->Unit = { equals(0, 1) }
val call_hashCode2: ()->Unit = { hashCode(2) }
val call_toString2: ()->Unit = { toString("3") }
}
public class PublicClassWithInternals {
fun equals(a: Any?): Boolean = this.identityEquals(a)
fun hashCode(): Int = 0
fun toString(): String = "public Bar"
}
class InternalClassWithInternals {
fun equals(a: Any?): Boolean = this.identityEquals(a)
fun hashCode(): Int = 1
fun toString(): String = "InternalClass"
// overloads
fun equals(a: Any?, b: Any?): Boolean = a == b
fun hashCode(i: Int): Int = i
fun toString(s: String): String = s
}
private class PrivateClassWithInternals {
fun equals(a: Any?): Boolean = this.identityEquals(a)
fun hashCode(): Int = 2
fun toString(): String = "InternalClass"
// overloads
fun equals(a: Any?, b: Any?): Boolean = a == b
fun hashCode(i: Int): Int = i
fun toString(s: String): String = s
}
public class PublicClassWithPrivates {
private fun equals(a: Any?): Boolean = this.identityEquals(a)
private fun hashCode(): Int = 0
private fun toString(): String = "public Bar"
val call_equals: ()->Unit = { equals(0) }
val call_hashCode: ()->Unit = { hashCode() }
val call_toString: ()->Unit = { toString() }
}
class InternalClassWithPrivates {
private fun equals(a: Any?): Boolean = this.identityEquals(a)
private fun hashCode(): Int = 1
private fun toString(): String = "InternalClass"
// overloads
private fun equals(a: Any?, b: Any?): Boolean = a == b
private fun hashCode(i: Int): Int = i
private fun toString(s: String): String = s
val call_equals: ()->Unit = { equals(0) }
val call_hashCode: ()->Unit = { hashCode() }
val call_toString: ()->Unit = { toString() }
val call_equals2: ()->Unit = { equals(0, 1) }
val call_hashCode2: ()->Unit = { hashCode(2) }
val call_toString2: ()->Unit = { toString("3") }
}
private class PrivateClassWithPrivates {
private fun equals(a: Any?): Boolean = this.identityEquals(a)
private fun hashCode(): Int = 2
private fun toString(): String = "InternalClass"
// overloads
private fun equals(a: Any?, b: Any?): Boolean = a == b
private fun hashCode(i: Int): Int = i
private fun toString(s: String): String = s
val call_equals: ()->Unit = { equals(0) }
val call_hashCode: ()->Unit = { hashCode() }
val call_toString: ()->Unit = { toString() }
val call_equals2: ()->Unit = { equals(0, 1) }
val call_hashCode2: ()->Unit = { hashCode(2) }
val call_toString2: ()->Unit = { toString("3") }
}
// Helpers
native
@@ -194,89 +74,26 @@ val STABLE_HASH_CODE = { hashCode()}.extractNames()[1]
val STABLE_TO_STRING = { toString()}.extractNames()[1]
fun box(): String {
testGroup = "Public Class with publics"
test(STABLE_EQUALS) { PublicClassWithPublics().equals(0) }
test(STABLE_HASH_CODE) { PublicClassWithPublics().hashCode() }
test(STABLE_TO_STRING) { PublicClassWithPublics().toString() }
testGroup = "Public Class"
test(STABLE_EQUALS) { PublicClass().equals(0) }
test(STABLE_HASH_CODE) { PublicClass().hashCode() }
test(STABLE_TO_STRING) { PublicClass().toString() }
testGroup = "Internal Class with publics"
test(STABLE_EQUALS) { InternalClassWithPublics().equals(0) }
test(STABLE_HASH_CODE) { InternalClassWithPublics().hashCode() }
test(STABLE_TO_STRING) { InternalClassWithPublics().toString() }
testGroup = "Internal Class"
test(STABLE_EQUALS) { InternalClass().equals(0) }
test(STABLE_HASH_CODE) { InternalClass().hashCode() }
test(STABLE_TO_STRING) { InternalClass().toString() }
//test(SIMPLE_EQUALS) { InternalClassWithPublics().equals(0, 1) }
//test(SIMPLE_HASH_CODE) { InternalClassWithPublics().hashCode(2) }
//test(SIMPLE_TO_STRING) { InternalClassWithPublics().toString("3") }
testGroup = "Private Class with publics"
test(STABLE_EQUALS) { PrivateClassWithPublics().equals(0) }
test(STABLE_HASH_CODE) { PrivateClassWithPublics().hashCode() }
test(STABLE_TO_STRING) { PrivateClassWithPublics().toString() }
testGroup = "Private Class"
test(STABLE_EQUALS) { PrivateClass().equals(0) }
test(STABLE_HASH_CODE) { PrivateClass().hashCode() }
test(STABLE_TO_STRING) { PrivateClass().toString() }
//test(SIMPLE_EQUALS) { PrivateClassWithPublics().equals(0, 1) }
//test(SIMPLE_HASH_CODE) { PrivateClassWithPublics().hashCode(2) }
//test(SIMPLE_TO_STRING) { PrivateClassWithPublics().toString("3") }
testGroup = "Public Class with protecteds"
test(STABLE_EQUALS, PublicClassWithProtecteds().call_equals)
test(STABLE_HASH_CODE, PublicClassWithProtecteds().call_hashCode)
test(STABLE_TO_STRING, PublicClassWithProtecteds().call_toString)
testGroup = "Internal Class with protecteds"
test(STABLE_EQUALS, InternalClassWithProtecteds().call_equals)
test(STABLE_HASH_CODE, InternalClassWithProtecteds().call_hashCode)
test(STABLE_TO_STRING, InternalClassWithProtecteds().call_toString)
//test(SIMPLE_EQUALS, InternalClassWithProtecteds().call_equals2)
//test(SIMPLE_HASH_CODE, InternalClassWithProtecteds().call_hashCode2)
//test(SIMPLE_TO_STRING, InternalClassWithProtecteds().call_toString2)
testGroup = "Private Class with protecteds"
test(STABLE_EQUALS, PrivateClassWithProtecteds().call_equals)
test(STABLE_HASH_CODE, PrivateClassWithProtecteds().call_hashCode)
test(STABLE_TO_STRING, PrivateClassWithProtecteds().call_toString)
//test(STABLE_EQUALS_OVERLOAD, PrivateClassWithProtecteds().call_equals2)
//test(STABLE_HASH_CODE_OVERLOAD, PrivateClassWithProtecteds().call_hashCode2)
//test(STABLE_TO_STRING_OVERLOAD, PrivateClassWithProtecteds().call_toString2)
testGroup = "Public Class with internals"
test(STABLE_EQUALS) { PublicClassWithInternals().equals(0) }
test(STABLE_HASH_CODE) { PublicClassWithInternals().hashCode() }
test(STABLE_TO_STRING) { PublicClassWithInternals().toString() }
testGroup = "Internal Class with internals"
test(STABLE_EQUALS) { InternalClassWithInternals().equals(0) }
test(STABLE_HASH_CODE) { InternalClassWithInternals().hashCode() }
test(STABLE_TO_STRING) { InternalClassWithInternals().toString() }
//test(SIMPLE_EQUALS) { InternalClassWithInternals().equals(0, 1) }
//test(SIMPLE_HASH_CODE) { InternalClassWithInternals().hashCode(2) }
//test(SIMPLE_TO_STRING) { InternalClassWithInternals().toString("3") }
testGroup = "Private Class with internals"
test(STABLE_EQUALS) { PrivateClassWithInternals().equals(0) }
test(STABLE_HASH_CODE) { PrivateClassWithInternals().hashCode() }
test(STABLE_TO_STRING) { PrivateClassWithInternals().toString() }
//test(SIMPLE_EQUALS) { PrivateClassWithInternals().equals(0, 1) }
//test(SIMPLE_HASH_CODE) { PrivateClassWithInternals().hashCode(2) }
//test(SIMPLE_TO_STRING) { PrivateClassWithInternals().toString("3") }
testGroup = "Public Class with privates"
test(STABLE_EQUALS, PublicClassWithPrivates().call_equals)
test(STABLE_HASH_CODE, PublicClassWithPrivates().call_hashCode)
test(STABLE_TO_STRING, PublicClassWithPrivates().call_toString)
testGroup = "Internal Class with privates"
test(STABLE_EQUALS, InternalClassWithPrivates().call_equals)
test(STABLE_HASH_CODE, InternalClassWithPrivates().call_hashCode)
test(STABLE_TO_STRING, InternalClassWithPrivates().call_toString)
//test(SIMPLE_EQUALS, InternalClassWithPrivates().call_equals2)
//test(SIMPLE_HASH_CODE, InternalClassWithPrivates().call_hashCode2)
//test(SIMPLE_TO_STRING, InternalClassWithPrivates().call_toString2)
testGroup = "Private Class with privates"
test(STABLE_EQUALS, PrivateClassWithPrivates().call_equals)
test(STABLE_HASH_CODE, PrivateClassWithPrivates().call_hashCode)
test(STABLE_TO_STRING, PrivateClassWithPrivates().call_toString)
//test(SIMPLE_EQUALS, PrivateClassWithPrivates().call_equals2)
//test(SIMPLE_HASH_CODE, PrivateClassWithPrivates().call_hashCode2)
//test(SIMPLE_TO_STRING, PrivateClassWithPrivates().call_toString2)
return "OK"
}