-
Notifications
You must be signed in to change notification settings - Fork 79
Improve custom pickler/unpickler generators #419
Improve custom pickler/unpickler generators #419
Conversation
* Keep compatibility with the same old API but improve significantly the way we report errors factoring out the most important ones and changing some of the error messages. * Factor out the functionality to register pickler generators (to be used at runtime) and make easier to add new ones for the missing types. * In tests, changes make sure that scala pickling is imported and that the deprecated method `generate` for Pickler and Unpickler is not used. * Apply minor changes throughout scala pickling.
* Remove some todos and make a better distinction between the runtime custom picklers and the runtime pickler registry. Merge the latter one in the `DefaultRuntimePicklerGenerator`. * Improve some docs w.r.t. the runtime custom picklers. * Make the `RuntimePicklerRegistry` more general for future custom picklers (like Either). * Remove annoying prints when running tests.
* Add custom runtime generators for Either and tests checking the new custom runtime generation. * Make `AnyPicklerUnpickler` deal with more corner cases. * Modify PicklingProtocol in sandbox-test and reuse it for both formats. * Add error for disabled runtime generation. * Improve the generator helper, make some renamings and add more documentation.
fff4c7e
to
3bc60b8
Compare
|
||
private[pickling] object Feedback { | ||
|
||
def failedGenerationMsg(x: String, y: String, z: String) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use different arg names than x/y/z? I'll be confused everytime I look at this method :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x= tpe, z = lookedFor, y = goal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll address this in a follow-up PR. Sorry! I was very haskell-ish (using a lazy-strategy).
This looks pretty great, nice work! A few comments (mostly useless), but a few questions as well. Nothing that has to be handled now. |
Thanks @jsuereth 😄 I'll address some stuff in my next PR. Currently, I'm trying to solve the scalajs problem and try these new changes with my custom picklers for spores! But I'll be doing this soon! |
* Add a new unrecognized tag error. * Abstract over `NoTypeHint`. * Fix `class` keyword repetition in `UnrecognizedClass`. * Mark stack as mutable.
* Add a new unrecognized tag error. * Abstract over `NoTypeHint`. * Fix `class` keyword repetition in `UnrecognizedClass`. * Mark stack as mutable.
* Add a new unrecognized tag error. * Abstract over `NoTypeHint`. * Fix `class` keyword repetition in `UnrecognizedClass`. * Mark stack as mutable.
* Add a new unrecognized tag error. * Abstract over `NoTypeHint`. * Fix `class` keyword repetition in `UnrecognizedClass`. * Mark stack as mutable.
* Add a new unrecognized tag error. * Abstract over `NoTypeHint`. * Fix `class` keyword repetition in `UnrecognizedClass`. * Mark stack as mutable.
Address fixes pointed out in #419
This PR improves how custom pickler/unpickler generators are created in both
scala pickling and third-party libraries that want to define their own for
concrete types.
It also improves error reporting significantly. Now we have concrete exceptions
for every kind of error that may happen. This improvement helps readability and
also gives a pretty straightforward idea of what could go wrong.
List of changes:
Add custom runtime generators for Either
Refactor runtime custom picklers
Improve error reporting