怎么拿到suspend方法的最后一个参数


#1

怎么拿到suspend方法的最后一个参数Continuation?或者调用其cancel和其他方法(通过查看字节码得知最后一个参数是Continuation)

  suspend fun <T> T?.checkAndGet(): T {
    ::checkAndGet.parameters//这里报错 'checkAndGet' is a member and an extension at the same time. References to such elements are not allowed
    return if (this@checkAndGet == null || !isActive()) {
        throw CancellationException()
    } else
        this@checkAndGet
}

#2
suspend fun <T> T?.checkAndGet() = suspendCoroutine<T> {
    continuation ->  
}

#3

谢谢,我试试


京ICP备16022265号-2 Kotlin China 2017 - 2018