Open jvican opened 8 years ago
@jvican Looks like that's a bug. There's a bit of funny-behavior regarding type parameters (usually my fault) in the macros.
Good, tomorrow I'll work on a fix for this.
The problem here is that we create FastTypeTag
s for type variables. I'm not sure if we should. Let me explain it with a bit of code:
trait Foo
case class Bar[T](v: T)
case class Zaz(i: Int)
Now, let's create a concrete pickler for Foo
:
def pickle(f: Foo, b: PBuilder): Unit = {
f match {
case b: Bar[t] =>
// t is a type variable and BarPickle gets an implicit `FastTypeTag`
// if we do not put a concrete tag here, one will be created for `t`
barPicklerUnpickler.pickle(b)
case z: Zaz => ???
}
}
I'm not very sure if this behavior is intended by scala pickling. But since a FastTypeTag
is a witness of a type, and we expect this type to be concrete, wouldn't be sensible to still consider this as a bug?
yes, I agree it looks like a bug. We shouldn't be able to grab a static type tag without some witness of t
's fast type tag
I wonder why this happens:
When using
AnyUnpickler
one wants to unpickle anything inferred from its type. In this case, reflection fails to create an unpickler for that type becauset
ands
are unknown. Why aren'tt
ands
concrete when they could beList[Int]
andList[String]
? Is this a bug? Otherwise, why doesn'tFastTypeTag
constructs the tag from the full type?/cc @jsuereth since he's been refactoring
FastTypeTag
lately.