Override "hashCode" and "equals" for Getter and Setter to fix KT-13490

This commit is contained in:
Xin Wang
2021-03-24 17:27:31 +08:00
committed by Alexander Udalov
parent 46d5e974df
commit c959b271a4
2 changed files with 54 additions and 15 deletions
@@ -157,6 +157,12 @@ internal abstract class KPropertyImpl<out V> private constructor(
}
override fun toString(): String = "getter of $property"
override fun equals(other: Any?): Boolean =
other is Getter<*> && property == other.property
override fun hashCode(): Int =
property.hashCode()
}
abstract class Setter<V> : Accessor<V, Unit>(), KMutableProperty.Setter<V> {
@@ -172,6 +178,12 @@ internal abstract class KPropertyImpl<out V> private constructor(
}
override fun toString(): String = "setter of $property"
override fun equals(other: Any?): Boolean =
other is Setter<*> && property == other.property
override fun hashCode(): Int =
property.hashCode()
}
companion object {