-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codec derivation issues upgrading from v6.0.0 to v7.0.0 #71
Comments
Thanks for the report @marko-asplund. Would you be interested in investigating what’s going on? |
@julienrf This issue is currently blocking Play v2.8 upgrade, so I'll need to figure out some kind of workaround. Any pointers for investigating the issue? |
I think you did a great job of sharing the test cases that fail. Thank you for this! The next step would be to debug which implicit definitions are used in both cases (with v6 and v7) to see where they diverge. The compiler plugin tek/splain could help a lot in this area. |
Thanks for the tip! 👍 I'll look into debugging using the plugin. 🤔 How do I get the plugin to output implicit definitions? I've tried setting this up in |
Hmm, I don’t know what’s wrong. Your setup looks good to me. Did you reload sbt? |
Yeah, I did try reloading and restarting sbt several times. |
This issue seems to have been caused by variance changes in play-json v2.7.4
play-json v2.8.1
This changed in commit playframework/play-json@ba86577#diff-43f2e42c6ce469bcd932a93a187413fe Because of this change |
Thanks for the investigation @marko-asplund! I guess for the second problem you’ll have to manually upcast your values: - val b2 = Json.toJson(Bar2("hello", 55))
+ val b2 = Json.toJson(Bar2("hello", 55): Foo2) The issue 1 is more problematic. I’m not sure how to fix it. |
@julienrf Thanks for the feedback! issue 1: issue 2: only IMO, though it's not an ideal solution, passing the desired type parameter to 🤔 Trying to figure out what play-json-derived-codecs could do to address this issue. |
Yes, that’s a good idea, thanks for proposing! We should provide the workarounds in the README. |
🤔 Also wondering what was the exact rationale for play-json to go this way. It would've been very helpful to publish a heads up about this e.g. in the form of breaking changes in v2.8 release notes. I couldn't find anything on this, at least not with a quick search and couldn't find release notes for v2.8 either. |
That’s a good point. Personally, I don’t understand this decision. |
Here's a possible workaround marko-asplund/play-json-derived-codecs-issue@fc0c7b0 |
It seems that they are aware of the problem: playframework/play-json#404 |
I'm bumped into two issues when upgrading to v7.0.0:
When upgrading from play-json-derived-codecs v6.0.0 to v7.0.0 Play JSON picks up a different JSON serializer in a scenario involving sum types when codecs for both the case classes and the sealed trait are in scope
codec derived for sealed trait doesn't appear to work for the case classes
Both of these issues can be reproduced with code found in this repository:
https://github.com/marko-asplund/play-json-derived-codecs-issue
The text was updated successfully, but these errors were encountered: