我一直在尝试将refined与scalatest一起使用,并且在#34; typer"阶段:trying to do lub/glb of typevar ?F[?T, ?B]
这是我尝试使用自包含的菊石脚本进行极简主义复制的最佳尝试:
import $ivy.`eu.timepit::refined:0.9.0`
import $ivy.`org.scalatestplus.play::scalatestplus-play:3.1.2`
import org.scalatest.{MustMatchers, WordSpec}
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
import eu.timepit.refined.auto.autoInfer
class RefinedSpec extends WordSpec with MustMatchers {
val duration = 500.millis
val fut = Future.successful("123")
Await.result(fut, atMost = duration)
}
如果您对上述内容进行以下任何一项更改,则会成功编译:
import eu.timepit.refined.auto.autoInfer
with MustMatchers
Await.result(fut, atMost = duration)
为了澄清,这是编译错误,而不是运行时错误。原始错误发生在播放应用程序(scala 2.11.11)中,同时在sbt中运行test:compile
,但使用菊石脚本可能更容易重现它。
使用的菊石版I提供版本信息:
Welcome to the Ammonite Repl 1.1.2
(Scala 2.11.12 Java 1.8.0_25)
使用以下方式安装:
sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/Ammonite/releases/download/1.1.2/2.11-1.1.2) > /usr/local/bin/amm && chmod +x /usr/local/bin/amm' && amm
来自菊石示例的更多错误详情:
scala.reflect.internal.FatalError:
trying to do lub/glb of typevar ?F[?T, ?B]
while compiling: fail.sc
during phase: typer
library version: version 2.11.12
compiler version: version 2.11.12
reconstructed args: -nowarn -Yresolve-term-conflict:object
last tree to typer: Ident(<argument>)
tree position: line 15 of fail.sc
tree tpe: String
symbol: <none>
symbol definition: <none> (a NoSymbol)
symbol package: <none>
symbol owners:
call site: class RefinedSpec in object fail in package $file
从播放sbt test:compile
我也得到了这种输出:
[error] last tree to typer: Ident(<argument>)
[error] tree position: line 13 of ...../RefinedSpec.scala
[error] tree tpe: String
[error] symbol: <none>
[error] symbol definition: <none> (a NoSymbol)
[error] symbol package: <none>
[error] symbol owners:
[error] call site: class RefinedSpec in package foo in package foo
[error]
[error] == Source file context for tree position ==
[error]
[error] 10 val duration = 500.millis
[error] 11 val fut = Future.successful("123")
[error] 12 Await.result(fut, atMost = duration)
[error] 13 }
这不是一个严重的问题因为我可以删除autoInfer
导入,因为我实际上没有使用它。它会引起人们的兴趣,因为他们倾向于这样做:
import eu.timepit.refined.auto._
从编译时常量到精炼类型的自动转换,当它们可能只是逃脱:
import eu.timepit.refined.auto.autoRefineV