如何修复Kotlin中的“对象不是抽象对象且未实现抽象成员”错误

时间:2019-06-19 05:35:43

标签: java kotlin ktor

我目前正在尝试进入Kotlin,我认为没有比运行一些用Kotlin编写的应用程序更好的学习方法了。因此,我在https://github.com/Kotlin/kotlin-fullstack-sample找到了这个示例项目,当我尝试运行它时,它给了我这个错误

我试图遵循那些苦苦挣扎的人提供的步骤,虽然这似乎是相同的问题,但没有帮助。


fun <T> async(block: suspend () -> T): Promise<T> = Promise<T> { resolve, reject ->
    block.startCoroutine(object : Continuation<T> {
        override val context: CoroutineContext get() = EmptyCoroutineContext
        override fun resume(value: T) { resolve(value) }
        override fun resumeWithException(exception: Throwable) { reject(exception) }
    })
}

这是一些提供错误信息的代码

Error:(12, 26) Kotlin: Object is not abstract and does not implement abstract member public abstract fun resumeWith(result: Result<T>): Unit defined in kotlin.coroutines.Continuation
Error:(14, 9) Kotlin: 'resume' overrides nothing
Error:(15, 9) Kotlin: 'resumeWithException' overrides nothing

这是输出

0 个答案:

没有答案