【问题标题】:Expecting a top-level declaration with Kotlin 1.3期待 Kotlin 1.3 的顶级声明
【发布时间】:2020-02-08 15:13:35
【问题描述】:

我对一些 Kotlin 代码有疑问。编译器 1.3 给出了三个错误:

  • 期待顶级声明
  • 期待成员声明
  • 期待顶级声明

但 intellij 编辑器并没有突出显示它。事实上,故障行上没有代码!

package io.robusta.nikotor.core

import java.util.*
import java.util.concurrent.CompletableFuture

interface PersistedEvent<E, P> where E : Event<P> {
    val event: E
    val sequenceId: Long
    val technicalDate: Long
}


typealias Persisted = PersistedEvent<*,*>
typealias Events = List<Event<*>>
typealias PersistedEvents = List<PersistedEvent<*,*>>
​
abstract class AbstractPersistedEvent<E, P>(override val event: E)
    : PersistedEvent<E, P> where E : Event<P> {
    ​
    override val technicalDate = Date().time
}
​
object LocalSequence{
    private var localSequenceId = 0L
    fun next(): Long {
        localSequenceId++
        return localSequenceId
    }
}


class SequencePersisted<E, P>(event: E) : AbstractPersistedEvent<E, P>(event) where E : Event<P> {
    override val sequenceId = LocalSequence.next()
}


interface EventStore {
    fun <P> persist(event: Event<P>): CompletableFuture<PersistedEvent<*,*>>

    fun persistAll(events: Events): CompletableFuture<PersistedEvents>

    fun loadInitialEvents(): CompletableFuture<PersistedEvents>

    fun resetWith(events: Events): CompletableFuture<PersistedEvents>
}

有什么想法吗?整个代码可以在这个提交中看到:https://github.com/nicolas-zozol/nikotor/commit/45bc9747f9ff2d1c0e08d95aaea3f3fd682a7519#diff-41897c89e00b2524fa66d59b846776d3

【问题讨论】:

    标签: kotlin


    【解决方案1】:

    您的代码中有\u200b 符号。你必须删除它们。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-01
    • 2013-06-12
    相关资源
    最近更新 更多