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 b1512930c..144ca4a07 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 @@ -11,6 +11,13 @@ inline class UnsafeWeakRef(private val weakRef: WeakRef) { fun get(): T = weakRef.get() ?: error("WeakRef is released") fun clear() = weakRef.clear() + /** + * Provides delegate value. + * + * ```kotlin + * val bot: Bot by param.unsafeWeakRef() + * ``` + */ operator fun getValue(thisRef: Any?, property: KProperty<*>): T? = this.get() }