mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-27 17:00:14 +08:00
Add warning for ifNull on non-null value
This commit is contained in:
parent
136b0c11d8
commit
453d072cc7
@ -41,11 +41,18 @@ internal fun StackFrame.findLoader(): ClassLoader? {
|
|||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
|
||||||
|
@kotlin.internal.LowPriorityInOverloadResolution
|
||||||
internal inline fun <T : Any> T?.ifNull(block: () -> T): T {
|
internal inline fun <T : Any> T?.ifNull(block: () -> T): T {
|
||||||
contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) }
|
contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) }
|
||||||
return this ?: block()
|
return this ?: block()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("DeprecatedCallableAddReplaceWith")
|
||||||
|
@Deprecated("Useless ifNull on not null value.")
|
||||||
|
@JvmName("ifNull1")
|
||||||
|
internal inline fun <T : Any> T.ifNull(block: () -> T): T = this
|
||||||
|
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal inline fun assertionError(message: () -> String = { "Reached an unexpected branch." }): Nothing {
|
internal inline fun assertionError(message: () -> String = { "Reached an unexpected branch." }): Nothing {
|
||||||
contract { callsInPlace(message, InvocationKind.EXACTLY_ONCE) }
|
contract { callsInPlace(message, InvocationKind.EXACTLY_ONCE) }
|
||||||
|
Loading…
Reference in New Issue
Block a user