scala编译错误: type mismatch; found: IndexedSeq[Int] required: scala. collection.immutable.Seq[Int]

标签 scala compiler-errors

不知道为什么下面的scala代码无法编译:

import collection.immutable.Seq
def foo(nodes: Seq[Int]) = null
val nodes:IndexedSeq[Int] = null
foo(nodes)

=>

error: type mismatch;
 found   : IndexedSeq[Int]
 required: scala.collection.immutable.Seq[Int]
             foo(nodes)
                 ^

在scala-library中,声明了IndexedSeq:

trait IndexedSeq[+A] extends Seq[A]...

最佳答案

有几个 IndexedSeq 特征。默认为 scala.collection.IndexedSeq。如果你导入collection.immutable.IndexedSeq那么scala将成功编译。 (从OP复制)

关于scala编译错误: type mismatch; found: IndexedSeq[Int] required: scala. collection.immutable.Seq[Int],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13540002/

相关文章:

scala - 使用类型成员作为自身类型

scala - 将 Elasticsearch 5.5批量提取API与Spark流一起使用时发生NullPointerException

scala - 如何根据值列表过滤 RDD

java - 执行 io 时 akka jvm 线程与 os 线程

scala slick 一对多集合

xcode - 如何获得Xcode “clang”编译时错误的调用?

twitter-bootstrap - Bootstrap 4 _bootstrap-variables.scss文件破坏了编译

c++11 - 如何解决在此范围内未声明的 “' shared_ptr错误?

c - 如何在 32 位运行 Microsoft 的 FourQ 库?

java - 这段代码有什么问题? Netbeans 不编译代码