我正在尝试使用 scala-pickling,因为在站点github 上它看起来非常简单和干净。但是,我在这个简单的REPL中使用它失败了:
scala> import scala.pickling._
import scala.pickling._
scala> import scala.pickling.Defaults._
import scala.pickling.Defaults._
scala> import binary._
import binary._
scala> class Xpto { var a = 0D; var b = 0 }
defined class Xpto
scala> val v = new Xpto { a = 1.23; b = 5 }
v: Xpto = $anon$1@636d2b03
scala> v.pickle
<console>:19: error: type mismatch;
found : v.type (with underlying type Xpto)
required: ?{def pickle: ?}
Note that implicit conversions are not applicable because they are ambiguous:
both method PickleOps in package pickling of type [T](picklee: T)pickling.PickleOps[T]
and method pickleOps in trait Ops of type [T](picklee: T)scala.pickling.PickleOps[T]
are possible conversion functions from v.type to ?{def pickle: ?}
v.pickle
^
<console>:19: error: value pickle is not a member of Xpto
v.pickle
^
怎么了?
我确实使用相同类型的问题访问了 StackOverflow 上的其他问题,例如:
Obs.:我在build.sbt中使用了这个参考:
"org.scala-lang.modules" %% "scala-pickling" % "0.10.1"