Skip to content
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

Avoid BootstrapMethodError errors during serialization #343

Merged
merged 4 commits into from
Jul 13, 2017

Conversation

travisbrown
Copy link

@travisbrown travisbrown commented Jul 13, 2017

This PR fixes #342 by replacing some of the function literals in generated code with explicit FunctionN values. Specifically the arbTupleN instances in ArbitraryArities now use Gen.zip, and all of the Gen.zip implementations now use flatMap and new Function1 instead of for-comprehensions.

Explicitly instantiating FunctionN values instead of using function literals means that we avoid this Scala 2.12 bug and the underlying JVM 8 limitations without having to use -Ydelambdafy:inline to get the old lambda encoding everywhere.

This doesn't affect binary compatibility but it does mean that the 2.12 jars are bigger. The Gen.zip implementations could probably be changed back once 2.12.3 is released with this fix, but I think the arbTupleN change is a little nicer anyway (and doesn't contribute to the jar size blowup).

I've added tests that fail on 2.12 with the BootstrapMethodError in #342 without this change.

I'm happy to reformat if needed (some of the code-gen-ed lines are now pretty long).

@rickynils rickynils merged commit 35d5948 into typelevel:master Jul 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Arbitrary functions are not serializable with Scala 2.12
3 participants