diff --git a/weak/src/commonMain/kotlin/algorithms/FakeWeakRef.kt b/weak/src/commonMain/kotlin/algorithms/FakeWeakRef.kt index cbe0705..d8ba3cc 100644 --- a/weak/src/commonMain/kotlin/algorithms/FakeWeakRef.kt +++ b/weak/src/commonMain/kotlin/algorithms/FakeWeakRef.kt @@ -39,4 +39,20 @@ class FakeWeakRef( fun clear() { value = null } + + override fun toString(): String = + if (value == null) "FakeWeakRef.Empty" else "FakeWeakRef($value)" + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is FakeWeakRef<*>) return false + + if (value != other.value) return false + + return true + } + + override fun hashCode(): Int { + return value?.hashCode() ?: 0 + } }