diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/ReceiveFriendAddRequestEvent.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/ReceiveFriendAddRequestEvent.kt index fbb549286..a376e4a1e 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/ReceiveFriendAddRequestEvent.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/ReceiveFriendAddRequestEvent.kt @@ -2,6 +2,7 @@ package net.mamoe.mirai.event.events import net.mamoe.mirai.contact.QQ import net.mamoe.mirai.data.EventPacket +import net.mamoe.mirai.utils.getValue import net.mamoe.mirai.utils.unsafeWeakRef import kotlin.jvm.JvmOverloads diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt index dc0fed8b4..a87465c55 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/GroupMessage.kt @@ -7,6 +7,7 @@ import net.mamoe.mirai.contact.MemberPermission import net.mamoe.mirai.event.BroadcastControllable import net.mamoe.mirai.message.data.At import net.mamoe.mirai.message.data.MessageChain +import net.mamoe.mirai.utils.getValue import net.mamoe.mirai.utils.unsafeWeakRef @Suppress("unused", "NOTHING_TO_INLINE") diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/WeakRef.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/WeakRef.kt index 801de596b..ff7aec931 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/WeakRef.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/WeakRef.kt @@ -2,7 +2,6 @@ package net.mamoe.mirai.utils -import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KProperty /** @@ -20,28 +19,7 @@ inline class UnsafeWeakRef(private val weakRef: WeakRef) { * val bot: Bot by param.unsafeWeakRef() * ``` */ -operator fun UnsafeWeakRef.provideDelegate(thisRef: Any?, property: KProperty<*>): ReadOnlyProperty { - return object : ReadOnlyProperty { - override fun getValue(thisRef: Any?, property: KProperty<*>): T { - return get() - } - } -} - -/** - * Provides delegate value. - * - * ```kotlin - * val bot: Bot? by param.weakRef() - * ``` - */ -operator fun WeakRef.provideDelegate(thisRef: Any?, property: KProperty<*>): ReadOnlyProperty { - return object : ReadOnlyProperty { - override fun getValue(thisRef: Any?, property: KProperty<*>): T? { - return get() - } - } -} +operator fun UnsafeWeakRef.getValue(thisRef: Any?, property: KProperty<*>): T = get() /** * Weak Reference.