Generate equals/hashCode(): Support content equality from stdlib

#KT-22361 Fixed
This commit is contained in:
Alexey Sedunov
2018-07-06 21:17:39 +03:00
parent 5fcc6cfa0b
commit b441c76313
5 changed files with 76 additions and 30 deletions
@@ -1,5 +1,3 @@
import java.util.Arrays
class A(val n: IntArray, val s: Array<String>) {
val f: Float = 1.0f
@@ -13,16 +11,16 @@ class A(val n: IntArray, val s: Array<String>) {
other as A
if (!Arrays.equals(n, other.n)) return false
if (!Arrays.equals(s, other.s)) return false
if (!n.contentEquals(other.n)) return false
if (!s.contentEquals(other.s)) return false
if (f != other.f) return false
return true
}
override fun hashCode(): Int {
var result = Arrays.hashCode(n)
result = 31 * result + Arrays.hashCode(s)
var result = n.contentHashCode()
result = 31 * result + s.contentHashCode()
result = 31 * result + f.hashCode()
return result
}