From b26b3bbfbc574ecb76a045113844cdde66c29c8c Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 21 Feb 2020 22:29:17 +0800 Subject: [PATCH] Fix `MemberImpl.equals` --- .../net/mamoe/mirai/qqandroid/ContactImpl.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt index 159082173..ada894249 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/ContactImpl.kt @@ -166,7 +166,7 @@ internal class QQImpl( } -@Suppress("MemberVisibilityCanBePrivate", "DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE") +@Suppress("MemberVisibilityCanBePrivate") internal class MemberImpl( qq: QQImpl, group: GroupImpl, @@ -286,6 +286,20 @@ internal class MemberImpl( } } + override fun hashCode(): Int { + var result = bot.hashCode() + result = 31 * result + id.hashCode() + return result + } + + @Suppress("DuplicatedCode") + override fun equals(other: Any?): Boolean { // 不要删除. trust me + if (this === other) return true + if (other !is Contact) return false + if (this::class != other::class) return false + return this.id == other.id && this.bot == other.bot + } + override fun toString(): String { return "Member($id)" }