mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-03 18:53:53 +08:00
Add contract
This commit is contained in:
parent
a49e97d2e6
commit
9caed32b17
@ -6,6 +6,8 @@ import net.mamoe.mirai.contact.Contact
|
|||||||
import net.mamoe.mirai.contact.QQ
|
import net.mamoe.mirai.contact.QQ
|
||||||
import net.mamoe.mirai.network.protocol.tim.packet.action.FriendImagePacket
|
import net.mamoe.mirai.network.protocol.tim.packet.action.FriendImagePacket
|
||||||
import net.mamoe.mirai.utils.ExternalImage
|
import net.mamoe.mirai.utils.ExternalImage
|
||||||
|
import kotlin.contracts.ExperimentalContracts
|
||||||
|
import kotlin.contracts.contract
|
||||||
import kotlin.js.JsName
|
import kotlin.js.JsName
|
||||||
import kotlin.jvm.Volatile
|
import kotlin.jvm.Volatile
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
@ -257,8 +259,12 @@ fun MessageChain(messages: Iterable<Message>): MessageChain = MessageChainImpl(m
|
|||||||
*
|
*
|
||||||
* @see Message.singleChain receiver 模式
|
* @see Message.singleChain receiver 模式
|
||||||
*/
|
*/
|
||||||
|
@UseExperimental(ExperimentalContracts::class)
|
||||||
@Suppress("FunctionName")
|
@Suppress("FunctionName")
|
||||||
fun SingleMessageChain(delegate: Message): MessageChain {
|
fun SingleMessageChain(delegate: Message): MessageChain {
|
||||||
|
contract {
|
||||||
|
returns() implies (delegate !is MessageChain)
|
||||||
|
}
|
||||||
require(delegate !is MessageChain) { "delegate for SingleMessageChain should not be any instance of MessageChain" }
|
require(delegate !is MessageChain) { "delegate for SingleMessageChain should not be any instance of MessageChain" }
|
||||||
return SingleMessageChainImpl(delegate)
|
return SingleMessageChainImpl(delegate)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user