picopickle
picopickle copied to clipboard
phase typer fails when using io.github.netvl.picopickle.backends.jawn.JsonPickler.
Following code results in lockup when compiling (phase typer):
case class Recipe(title: String, description: Option[String] = None, ingredients: Seq[Ingredient],
directions: Seq[String], images: Option[Seq[String]] = None)
val baseRecipe = new Recipe(title = "A Recipe", description = Option(""), ingredients = Seq(),
directions = Seq(), images = None)
val write1 = writeString(baseRecipe)
Thanks, I'll look into it. Although these errors are very hard to debug and fix in Scala, unfortunately - lots of macro and implicit machinery are deeply magical and can refuse to work for no apparent reason whatsoever.
As a workaround, you can try adding explicit instantiations of Reader
/Writer
, like this:
object CustomPickler extends JsonPickler {
// write here readwriters for other custom types which Ingredient depends on
implicit val ingredientReadWriter = ReadWriter[Ingredient]
implicit val recipeReadWriter = ReadWriter[Recipe]
}
CustomPickler.writeString(baseRecipe)
It may work but it may just as well not. Could you also please give the definition of Ingredient
and other custom case classes which are transitively used by it?