mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-09 09:50:16 +08:00
Add BuilderInference to selectMessages and whileSelectMessages
This commit is contained in:
parent
945bcc9b5b
commit
79242ed483
@ -56,11 +56,12 @@ import net.mamoe.mirai.utils.MiraiExperimentalApi
|
|||||||
* @see nextMessage 挂起协程并等待下一条消息
|
* @see nextMessage 挂起协程并等待下一条消息
|
||||||
*/
|
*/
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
|
@BuilderInference
|
||||||
public suspend inline fun <reified T : MessageEvent> T.whileSelectMessages(
|
public suspend inline fun <reified T : MessageEvent> T.whileSelectMessages(
|
||||||
timeoutMillis: Long = -1,
|
timeoutMillis: Long = -1,
|
||||||
filterContext: Boolean = true,
|
filterContext: Boolean = true,
|
||||||
priority: Listener.EventPriority = EventPriority.MONITOR,
|
priority: Listener.EventPriority = EventPriority.MONITOR,
|
||||||
crossinline selectBuilder: @MessageDsl MessageSelectBuilder<T, Boolean>.() -> Unit
|
@BuilderInference crossinline selectBuilder: @MessageDsl MessageSelectBuilder<T, Boolean>.() -> Unit
|
||||||
): Unit = whileSelectMessagesImpl(timeoutMillis, filterContext, priority, selectBuilder)
|
): Unit = whileSelectMessagesImpl(timeoutMillis, filterContext, priority, selectBuilder)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,11 +69,12 @@ public suspend inline fun <reified T : MessageEvent> T.whileSelectMessages(
|
|||||||
*/
|
*/
|
||||||
@MiraiExperimentalApi
|
@MiraiExperimentalApi
|
||||||
@JvmName("selectMessages1")
|
@JvmName("selectMessages1")
|
||||||
|
@BuilderInference
|
||||||
public suspend inline fun <reified T : MessageEvent> T.selectMessagesUnit(
|
public suspend inline fun <reified T : MessageEvent> T.selectMessagesUnit(
|
||||||
timeoutMillis: Long = -1,
|
timeoutMillis: Long = -1,
|
||||||
filterContext: Boolean = true,
|
filterContext: Boolean = true,
|
||||||
priority: Listener.EventPriority = EventPriority.MONITOR,
|
priority: Listener.EventPriority = EventPriority.MONITOR,
|
||||||
crossinline selectBuilder: @MessageDsl MessageSelectBuilderUnit<T, Unit>.() -> Unit
|
@BuilderInference crossinline selectBuilder: @MessageDsl MessageSelectBuilderUnit<T, Unit>.() -> Unit
|
||||||
): Unit = selectMessagesImpl(timeoutMillis, true, filterContext, priority, selectBuilder)
|
): Unit = selectMessagesImpl(timeoutMillis, true, filterContext, priority, selectBuilder)
|
||||||
|
|
||||||
|
|
||||||
@ -97,12 +99,12 @@ public suspend inline fun <reified T : MessageEvent> T.selectMessagesUnit(
|
|||||||
* @see nextMessage 挂起协程并等待下一条消息
|
* @see nextMessage 挂起协程并等待下一条消息
|
||||||
*/
|
*/
|
||||||
@Suppress("unused") // false positive
|
@Suppress("unused") // false positive
|
||||||
// @BuilderInference // https://youtrack.jetbrains.com/issue/KT-37716
|
@BuilderInference
|
||||||
public suspend inline fun <reified T : MessageEvent, R> T.selectMessages(
|
public suspend inline fun <reified T : MessageEvent, R> T.selectMessages(
|
||||||
timeoutMillis: Long = -1,
|
timeoutMillis: Long = -1,
|
||||||
filterContext: Boolean = true,
|
filterContext: Boolean = true,
|
||||||
priority: Listener.EventPriority = EventPriority.MONITOR,
|
priority: Listener.EventPriority = EventPriority.MONITOR,
|
||||||
// @BuilderInference
|
@BuilderInference
|
||||||
crossinline selectBuilder: @MessageDsl MessageSelectBuilder<T, R>.() -> Unit
|
crossinline selectBuilder: @MessageDsl MessageSelectBuilder<T, R>.() -> Unit
|
||||||
): R =
|
): R =
|
||||||
selectMessagesImpl(
|
selectMessagesImpl(
|
||||||
|
Loading…
Reference in New Issue
Block a user