mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +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()
|
||||
}
|
||||
|
||||
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER")
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
internal inline fun <T : Any> T?.ifNull(block: () -> T): T {
|
||||
contract { callsInPlace(block, InvocationKind.AT_MOST_ONCE) }
|
||||
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
|
||||
internal inline fun assertionError(message: () -> String = { "Reached an unexpected branch." }): Nothing {
|
||||
contract { callsInPlace(message, InvocationKind.EXACTLY_ONCE) }
|
||||
|
Loading…
Reference in New Issue
Block a user