Browse Source

Adjust param type: accept null in `UnsafeWeakRef<T>.getValue`

Him188 6 years ago
parent
commit
b0d274dd1a
1 changed files with 2 additions and 2 deletions
  1. 2 2
      mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/WeakRef.kt

+ 2 - 2
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/WeakRef.kt

@@ -30,7 +30,7 @@ inline class UnsafeWeakRef<T>(private val weakRef: WeakRef<T>) {
  * val bot: Bot by param.unsafeWeakRef()
  * ```
  */
-operator fun <T> UnsafeWeakRef<T>.getValue(thisRef: Any?, property: KProperty<*>): T = get()
+operator fun <T> UnsafeWeakRef<T>.getValue(thisRef: Any?, property: KProperty<*>?): T = get()
 
 /**
  * Weak Reference.
@@ -84,7 +84,7 @@ fun <T> T.unsafeWeakRef(): UnsafeWeakRef<T> = UnsafeWeakRef(this.weakRef())
  * val bot: Bot? by param.weakRef()
  * ```
  */
-operator fun <T> WeakRef<T>.getValue(thisRef: Any?, property: KProperty<*>): T? = this.get()
+operator fun <T> WeakRef<T>.getValue(thisRef: Any?, property: KProperty<*>?): T? = this.get()
 
 /**
  * Call the block if the referent is absent