Scala IntelliJ won';你不让我使用实现方法吗?

Scala IntelliJ won';你不让我使用实现方法吗?,scala,intellij-idea,Scala,Intellij Idea,我正在尝试编译IntelliJ中的以下类: class QueryIterator[E](query: => E) extends Iterator[E] { private var n: Option[Option[E]] = None private def cache() = { if (n.isEmpty) try { n = Some(Some(query)) } catch { case _: Exception => n = So

我正在尝试编译IntelliJ中的以下类:

class QueryIterator[E](query: => E) extends Iterator[E] {
  private var n: Option[Option[E]] = None
  private def cache() = {
    if (n.isEmpty)
      try { n = Some(Some(query)) }
      catch { case _: Exception => n = Some(None) }
  }
  private def uncache() =
    n = None
  override def hasNext: Boolean = {
    cache()
    n.get.isDefined
  }
  override def next(): E = {
    cache()
    val r = n.get.get
    uncache()
    r
  }
  override def toMap[K, V](implicit ev: <:<[E, (K, V)]): GenMap[K, V] = ???
  def iterable: Iterable[E] =
    new AbstractIterable[E] {
      override def iterator: Iterator[E] = QueryIterator.this
      override def toMap[K, V](implicit ev: <:<[E, (K, V)]): GenMap[K, V] = ???
    }
}
class QueryIterator[E](查询:=>E)扩展迭代器[E]{
私有变量n:Option[Option[E]]=None
专用def缓存()={
如果
试试{n=Some(Some(query))}
catch{case}:Exception=>n=Some(None)}
}
私有def uncache()=
n=无
覆盖def hasNext:Boolean={
缓存()
n、 得到定义
}
覆盖def next():E={
缓存()
val r=n.get.get
uncache()
r
}

override def toMap[K,V](隐式ev:错误消息告诉您一切:

您的签名:

def toMap[K, V](implicit ev: <:<[E, (K, V)]): GenMap[K, V]
GenMap
替换为
immutable.Map
,它就可以正常编译了


(*)在这两个类中,方法都是从继承的。请确保单击“完整签名”。

谢谢,解决了问题!签名是由IntelliJ生成的,因此我不知道它为什么出错。
def toMap[K, V](implicit ev: <:<[E, (K, V)]): immutable.Map[K, V]