Fix unresolved references

This commit is contained in:
Him188 2020-01-17 16:49:11 +08:00
parent 13d751c222
commit fea268d31f
3 changed files with 3 additions and 23 deletions

View File

@ -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

View File

@ -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")

View File

@ -2,7 +2,6 @@
package net.mamoe.mirai.utils
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
/**
@ -20,28 +19,7 @@ inline class UnsafeWeakRef<T>(private val weakRef: WeakRef<T>) {
* val bot: Bot by param.unsafeWeakRef()
* ```
*/
operator fun <T> UnsafeWeakRef<T>.provideDelegate(thisRef: Any?, property: KProperty<*>): ReadOnlyProperty<Any?, T> {
return object : ReadOnlyProperty<Any?, T> {
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
return get()
}
}
}
/**
* Provides delegate value.
*
* ```kotlin
* val bot: Bot? by param.weakRef()
* ```
*/
operator fun <T> WeakRef<T>.provideDelegate(thisRef: Any?, property: KProperty<*>): ReadOnlyProperty<Any?, T?> {
return object : ReadOnlyProperty<Any?, T?> {
override fun getValue(thisRef: Any?, property: KProperty<*>): T? {
return get()
}
}
}
operator fun <T> UnsafeWeakRef<T>.getValue(thisRef: Any?, property: KProperty<*>): T = get()
/**
* Weak Reference.