You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.
scala>importscala.pickling._importscala.pickling._
scala>importjson._importjson._
scala>traitFruit
defined traitFruit
scala>caseclassApple() extendsFruit
defined classApple// This works just fine:
scala>Apple().pickle.unpickle[Fruit]
res0:Fruit=Apple()
but when I define function to unpickle any instance of type T or any instance derived from trait T, it fails
scala> unpickle[Fruit](Apple().pickle)
scala.NotImplementedError: an implementation is missing
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:252)
at scala.pickling.PicklerUnpicklerNotFound.unpickle(Custom.scala:20)
at .unpickle(<console>:13)
at .<init>(<console>:18)
at .<clinit>(<console>)
at .<init>(<console>:7)
at .<clinit>(<console>)
at $print(<console>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:734)
at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:983)
at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:573)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:604)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:568)
at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:745)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:790)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:702)
at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:566)
at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:573)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:576)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:867)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
at scala.tools.nsc.interpreter.ILoop.main(ILoop.scala:889)
at xsbt.ConsoleInterface.run(ConsoleInterface.scala:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
at sbt.compiler.AnalyzingCompiler.console(AnalyzingCompiler.scala:77)
at sbt.Console.sbt$Console$$console0$1(Console.scala:23)
at sbt.Console$$anonfun$apply$2$$anonfun$apply$1.apply$mcV$sp(Console.scala:24)
at sbt.TrapExit$.sbt$TrapExit$$executeMain$1(TrapExit.scala:33)
at sbt.TrapExit$$anon$1.run(TrapExit.scala:42)
Function works fine with concrete type:
scala> unpickle[Apple](Apple().pickle)
res1:Apple=Apple()
Thanks a lot,
Milan
The text was updated successfully, but these errors were encountered:
Welcome to Scala version 2.10.4 (JavaHotSpot(TM) 64-BitServerVM, Java1.7.0_51).
Type in expressions to have them evaluated.
Type:help for more information.
scala>importscala.pickling._, Defaults._importscala.pickling._importDefaults._
scala>importjson._importjson._
scala>:paste
// Entering paste mode (ctrl-D to finish)traitFruitcaseclassApple() extendsFruit// Exiting paste mode, now interpreting.
defined traitFruit
defined classApple
scala>Apple().pickle.unpickle[Fruit]
res0:Fruit=Apple()
scala>defunpickle[T:Unpickler:FastTypeTag](p : JSONPickle) = p.unpickle[T]
unpickle: [T](p: scala.pickling.json.JSONPickle)(implicitevidence$1: scala.pickling.Unpickler[T], implicitevidence$2: scala.pickling.FastTypeTag[T])T
scala> unpickle[Fruit](Apple().pickle)
res1:Fruit=Apple()
Hello, here is the problem:
but when I define function to unpickle any instance of type T or any instance derived from trait T, it fails
problem
Thanks a lot,
Milan
The text was updated successfully, but these errors were encountered: