-
Notifications
You must be signed in to change notification settings - Fork 79
Runtime crash when pickling a FastTypeTag #32
Comments
Using json instead of binary gives a more explicit error:
The class is not found (plus some type erasure). Interesting... new FastTypeTag[Nothing] {
def mirror = mirror0
def tpe = tpe0
def key = key0
} Where A more expected exception would be:
As for example this snippet produces: trait A{}
val test: A = new A{}
val pickee = test.pickle
println(pickee)
val unpickee = pickee.unpickle[A] However, due to type erasure, it tries to find a corresponding class definition with any matching type [T] to instantiate it with... and do not find any.
As for example this snippet produces ( trait A[Int]{}
val test: A[Int] = new A[Int]{}
val pickee = test.pickle
println(pickee)
val unpickee = pickee.unpickle[A[Int]] tl;dr: you cannot unpickle into an anonymous class extending an abstract (trait) type, and due to type erasure the exception is confusing. EDIT: EDIT2: val test = implicitly[FastTypeTag[Int]]
val pickee = test.pickle
println(pickee)
// val unpickee = pickee.unpickle[FastTypeTag[Int]] // Fails Output:
We can see that the type is strange, some sort of definition of the anonymous class |
Thanks for the detailed response. I was trying to store a type in a database record for PersistentMap, so I could verify the table type when I connect to it. |
The current plan is to provide picklers for |
Fixes #32 - runtime crash for FastTypeTag pickling.
@phaller I just pushed a brancht hat has a FastTypeTag provided pickler (works with runtime pickling too). I'll add some tests and get it into 0.11.x. cc @emchristiansen |
Maybe it's a bit weird, but I want to serialize a FastTypeTag, so I can do type verification for a type-safe key-value store I hacked together.
Unfortunately, while the pickling seems to work, unpickling causes a runtime error.
steps
This code:
problem
fails with this runtime error:
The text was updated successfully, but these errors were encountered: