mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-24 06:50:08 +08:00
Fix weakRef
This commit is contained in:
parent
6bfd11b091
commit
aebaf605a7
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package net.mamoe.mirai.utils
|
package net.mamoe.mirai.utils
|
||||||
|
|
||||||
|
import kotlin.properties.ReadOnlyProperty
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,7 +19,13 @@ inline class UnsafeWeakRef<T>(private val weakRef: WeakRef<T>) {
|
|||||||
* val bot: Bot by param.unsafeWeakRef()
|
* val bot: Bot by param.unsafeWeakRef()
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): T = this.get()
|
operator fun provideDelegate(thisRef: Any?, property: KProperty<*>): ReadOnlyProperty<Any?, T> {
|
||||||
|
return object : ReadOnlyProperty<Any?, T> {
|
||||||
|
override fun getValue(thisRef: Any?, property: KProperty<*>): T {
|
||||||
|
return get()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user