Add contract

This commit is contained in:
Him188 2020-01-10 22:48:57 +08:00
parent ff2f0b5ae3
commit 70201af1c8

View File

@ -1,7 +1,17 @@
package net.mamoe.mirai.qqandroid.utils package net.mamoe.mirai.qqandroid.utils
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
/** /**
* Inline the block * Inline the block
*/ */
@UseExperimental(ExperimentalContracts::class)
@PublishedApi @PublishedApi
internal inline fun <R> inline(block: () -> R): R = block() internal inline fun <R> inline(block: () -> R): R {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block()
}