【发布时间】:2019-07-07 15:00:02
【问题描述】:
我试图在 Scala 2.13.0 中使用两个 ParRanges(并行范围)来执行任意操作,但我似乎缺少一些依赖项并且不确定它是什么。
我正在 IntelliJ IDEA Ultimate 2019.1.3 中开发游戏,使用 Libgdx 框架 v1.9.9,在 Scala 2.13.0 中使用 Gradle 进行依赖管理
我的全局库中有 Scala 2.13.0 SDK,并且我已将这些依赖项(以及其他)导入到我的 build.gradle 项目中:
<... rest of build.gradle file above>
project(":desktop") {
apply plugin: "java"
apply plugin: "scala"
dependencies {
compile "org.scala-lang:scala-library:2.13.0"
<other dependencies>
}
}
project(":core") {
apply plugin: "java"
apply plugin: "scala"
dependencies {
compile "org.scala-lang:scala-library:2.13.0"
compile "org.scala-lang.modules:scala-parallel-collections_2.13.0-M2:1.0.2"
<other dependencies>
}
}
<... rest of build.gradle file below>
有问题的示例代码是:
ParRange(0, Width, 1, true).foreach(x => {
ParRange(0, Height, 1, true).foreach(y => {
pixmap.setColor(Math.random().toFloat, Math.random().toFloat, Math.random().toFloat, 1)
pixmap.drawPixel(x, y)
})
})
当我尝试运行该程序时,我同样遇到了几个运行时错误:
Error:(29, 27) Symbol 'type scala.collection.generic.GenericTraversableTemplate' is missing from the classpath.
This symbol is required by 'trait scala.collection.generic.GenericParTemplate'.
Make sure that type GenericTraversableTemplate is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'GenericParTemplate.class' was compiled against an incompatible version of scala.collection.generic.
ParRange(0, Width, 1, true).foreach(x => {
还缺少:
'type scala.collection.GenIterableLike'
'type scala.collection.Parallel'
'type scala.collection.GenSeqLike'
'type scala.Immutable'
为了使用并行集合,我花了很多时间弄清楚我应该在 build.gradle 中导入什么依赖项。
根据 2.12.1 的 ScalaDocs,这些都应该存在:参见 https://www.scala-lang.org/api/2.12.1/scala/collection/generic/GenericTraversableTemplate.html
但是,2.13.0 的 ScalaDocs 显示这些都缺失:请参阅 https://www.scala-lang.org/api/2.13.0/scala/collection/generic/index.html
为什么 Scala 2.13.0 的并行集合依赖于 Scala 2.12.1 中存在的类和特征,而不是 Scala 2.13.0 中的类和特征?
【问题讨论】:
-
我向 Scala 团队报告了一个错误:github.com/scala/bug/issues/11616