From 70201af1c8a1a6206188eb0850977d9516c9a451 Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 10 Jan 2020 22:48:57 +0800 Subject: [PATCH] Add contract --- .../kotlin/net/mamoe/mirai/qqandroid/utils/inline.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/inline.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/inline.kt index 432ed9890..417258961 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/inline.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/utils/inline.kt @@ -1,7 +1,17 @@ package net.mamoe.mirai.qqandroid.utils +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract + /** * Inline the block */ +@UseExperimental(ExperimentalContracts::class) @PublishedApi -internal inline fun inline(block: () -> R): R = block() \ No newline at end of file +internal inline fun inline(block: () -> R): R { + contract { + callsInPlace(block, InvocationKind.EXACTLY_ONCE) + } + return block() +} \ No newline at end of file