3

The example below pickles fine, but I get a compile error stating that no unpickler can be generated. Here is a simple test case to reproduce this:

import scala.pickling._
import json._
object JsonTest extends App {
  val simplePickle = new Simple(new SimpleProp("TestProp")).pickle
  val simpleUnpickle = simplePickle.unpickle[Simple]
}
abstract class SimpleAbstract(val stringWrapper: SimpleProp) {}
class Simple(stringWrapper: SimpleProp) extends SimpleAbstract(stringWrapper) {}
case class SimpleProp(prop: String) {}

Please let me know if you need any additional information on this.

Here is the stacktrace I get with the -Xlog-implicits flag on:

    pickling.this.Unpickler.genUnpickler is not a valid implicit value for scala.pickling.Unpickler[com.ft.flexui.modules.pm.Simple] because:
exception during macro expansion: 
java.util.NoSuchElementException: None.get
    at scala.None$.get(Option.scala:313)
    at scala.None$.get(Option.scala:311)
    at scala.pickling.Macro.reflectively(Tools.scala:380)
    at scala.pickling.UnpicklerMacros$$anonfun$impl$2$$anonfun$16.apply(Macros.scala:248)
    at scala.pickling.UnpicklerMacros$$anonfun$impl$2$$anonfun$16.apply(Macros.scala:245)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:251)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:251)
    at scala.collection.AbstractTraversable.flatMap(Traversable.scala:105)
    at scala.pickling.UnpicklerMacros$$anonfun$impl$2.unpickleObject$1(Macros.scala:245)
    at scala.pickling.UnpicklerMacros$$anonfun$impl$2.unpickleLogic$1(Macros.scala:273)
    at scala.pickling.UnpicklerMacros$$anonfun$impl$2.apply(Macros.scala:291)
    at scala.pickling.UnpicklerMacros$$anonfun$impl$2.apply(Macros.scala:184)
    at scala.pickling.Macro.preferringAlternativeImplicits(Tools.scala:357)
    at scala.pickling.UnpicklerMacros$class.impl(Macros.scala:184)
    at scala.pickling.Compat$$anon$3.impl(Compat.scala:24)
    at scala.pickling.Compat$.UnpicklerMacros_impl(Compat.scala:25)
    at sun.reflect.GeneratedMethodAccessor270.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3$$anonfun$apply$8.apply(Macros.scala:544)
    at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3$$anonfun$apply$8.apply(Macros.scala:544)
    at scala.tools.nsc.typechecker.Macros$class.scala$tools$nsc$typechecker$Macros$$macroExpandWithRuntime(Macros.scala:830)
    at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroExpand1$1.apply(Macros.scala:796)
    at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroExpand1$1.apply(Macros.scala:787)
    at scala.tools.nsc.Global.withInfoLevel(Global.scala:190)
    at scala.tools.nsc.typechecker.Macros$class.scala$tools$nsc$typechecker$Macros$$macroExpand1(Macros.scala:787)
  val simpleUnpickle = simplePickle.unpickle[Simple]
                                            ^
DaoWen
  • 32,589
  • 6
  • 74
  • 101
kevin z
  • 75
  • 3

1 Answers1

1

That's a bug for sure.

We lodged a ticket, and fixed it. The updated jar should appear on Sonatype within the hour.

Testing it with the new jar in the REPL, all is now good:

scala> :paste
// Entering paste mode (ctrl-D to finish)

import scala.pickling._
import json._
object JsonTest extends App {
  val simplePickle = new Simple(new SimpleProp("TestProp")).pickle
  val simpleUnpickle = simplePickle.unpickle[Simple]
}
abstract class SimpleAbstract(val stringWrapper: SimpleProp) {}
class Simple(stringWrapper: SimpleProp) extends SimpleAbstract(stringWrapper) {}
case class SimpleProp(prop: String) {}


// Exiting paste mode, now interpreting.

import scala.pickling._
import json._
defined module JsonTest
defined class SimpleAbstract
defined class Simple
defined class SimpleProp
Heather Miller
  • 3,901
  • 1
  • 23
  • 19
  • Yup, I pulled the update and it's working correctly for me now as well. Thanks again for the quick turn around. This project is really cool and exactly what we were looking for in our project. Hopefully we can integrate it very soon. Do you want me to continue to report issues on SO or is there somewhere else you would prefer? – kevin z Oct 18 '13 at 18:32
  • Thanks for the kind words, and apologies for the delay. The best place to submit errors would be the [scala/pickling issue tracker](https://github.com/scala/pickling/issues?state=open). Thanks for reporting these! – Heather Miller Oct 24 '13 at 17:20