Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Flaw in algorithm? #395

Open
jvican opened this issue Apr 2, 2016 · 2 comments
Open

Flaw in algorithm? #395

jvican opened this issue Apr 2, 2016 · 2 comments

Comments

@jvican
Copy link
Member

jvican commented Apr 2, 2016

I'm trying to generate picklers and unpicklers for Spores. One problem I'm hitting is that despite having static picklers/unpicklers for a given Spore, scala-pickling generates their own brand-new picklers/unpicklers. For instance, let's say we have this:

case class B[S](value: S)
val s: Spore[T, B[S]] = ???
implicitly[Pickler[Spore[T, B[S]]]
implicitly[Unpickler[Spore[T, B[S]]]

Types T and S are concrete in the call site.

The aforementioned problem appears when we don't have a Pickler/Unpickler for B. Therefore, scala-pickling will infer that there's no Pickler/Unpickler for the spore type and generate them as well.

In my opinion, a fix for this problem is to change how the algorithm proceeds. If there's no Pickler/Unpickler for B, we generate them and then check if there's now a Pickler/Unpickler that matches Spore[T,S] and compose them.

If my previous analysis is not correct, this may be a problem caused by a bad registration of Picklers and Unpicklers. I'm using HybridRuntime. Also note that I am not using staticOnly.

This only affects scala pickling v0.11.x.

@jvican
Copy link
Member Author

jvican commented Apr 2, 2016

Just want to clarify that the Picklers/Unpicklers of Spore are not generated in the call site. I propagate the Picklers/Unpicklers of S through my API and then at some point invoke those implicitly. If before those statements I place implicitly[B[S]], the problem disappears because scala pickling detects a type R (B[S]) which is able to fit in Spore[T, R].

@jsuereth
Copy link
Member

Can you place a small reproducable example? I'm having trouble seeing this myself, and I'd like to try to fix it.

Note: one of my larger TODO items is to clean up how dependent-picklers are looked up in teh macros. Right now it's a recursive chain of macro-invocation for implciitly finding picklers. may remain that way, but be less flaky in the future...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants