scala / pickling

Fast, customizable, boilerplate-free pickling support for Scala
lampwww.epfl.ch/~hmiller/pickling
BSD 3-Clause "New" or "Revised" License
831 stars 79 forks source link

Variadic arguments for case class #436

Open dzufferey opened 8 years ago

dzufferey commented 8 years ago

Pickling fails to generate a pickler for case classes with variadic arguments.

Here is an example that fails to compile with Cannot generate a pickler:

import scala.pickling._, scala.pickling.Defaults._, json._

case class Sum(vs: Int*)

val s = Sum(0, 1, 2, 3, 4)
val pckl = s.pickle

I'm not sure if this use case should be supported by pickling or not. If this is not something that should be supported by pickling, can you give me some advice on how to write custom picklers for similar cases.

Thank you

jvican commented 8 years ago

Hi @dzufferey!

Yes, indeed, this is a case supported by scala pickling. Which version are you using? Please, could you bump up to 0.11.0-M2? We have tons of tests checking that this works. Either your real-world example is more complex than the shown code snippet OR you're using a very very old version of scala-pickling.

Also, note that it's recommended to import static._ as well, so that all the generated picklers don't rely on reflection. Let me know how it goes.

jvican commented 8 years ago

Well, actually I just tested this, and as you reported it's not working. I assumed that the vararg arguments was converted to Seq but it's converted ot WrappedArray. So, I'll add tests and fix this.

How urgent is this for you? @dzufferey

dzufferey commented 8 years ago

Hi @jvican,

It is not urgent. Just let me know when it is fixed.

I discussed this with @phaller and he recommended that I open an issue. That was a few months ago, so no urgency at all.

Thanks.

jvican commented 8 years ago

That's great, I'll take care of it @dzufferey !

Hope to get back to you soon.