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

Synthesize productIterator for AnyVal case classes only #10158

Closed
wants to merge 1 commit into from

Conversation

joroKr21
Copy link
Member

We can't reuse the inherited method from Product when the case class is AnyVal, because then the productIterator$extension would be missing from the companion. This restores binary compatibility with Scala 2.13.8 for AnyVal case classes.

Alternative to #10155

@scala-jenkins scala-jenkins added this to the 2.13.10 milestone Sep 24, 2022
@joroKr21 joroKr21 marked this pull request as ready for review September 24, 2022 09:52
@SethTisue SethTisue added the prio:blocker release blocker (used only by core team, only near release time) label Sep 24, 2022
Copy link
Contributor

@som-snytt som-snytt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comment on the other PR stands: it's a complication for no gain.

The alternative patch would be to generate only the value class extension method (for binary compatibility), which would just box and invoke the (mixin) method (instead of typedProductIterator). But that is also no practical gain.

My other joke was that the body could be just Iterator.single(value). That has the virtue of novelty.

@joroKr21
Copy link
Member Author

joroKr21 commented Sep 24, 2022

Maybe I misunderstood your comment. I thought you'd be fine with it if I implemented it. I don't see it as much of a complication since we already treat AnyVal case classes differently. They gain is less code in general out there in the world which is good thing in my book. That hasn't changed since the original PR from Scala 2.13.9

@som-snytt
Copy link
Contributor

Well, "fool me twice," "once bitten", etc. There must be an idiom for getting burned.

The same code is produced, it doesn't matter whether it's generated by mixin or case class. Both implementations just delegate to equivalent code.

After my PR is merged, to relieve my conscience, it's OK with me if Lukas likes this PR to further amend it.

@SethTisue SethTisue added release-notes worth highlighting in next release notes and removed prio:blocker release blocker (used only by core team, only near release time) labels Sep 29, 2022
@SethTisue SethTisue modified the milestones: 2.13.10, 2.13.11 Sep 30, 2022
@SethTisue
Copy link
Member

Unless someone wants to make a convincing argument to the contrary very soon, let's stick with #10155 for 2.13.10, and then consider this one for 2.13.11.

@SethTisue SethTisue removed the release-notes worth highlighting in next release notes label Sep 30, 2022
@joroKr21 joroKr21 force-pushed the product-iter branch 2 times, most recently from 6c3fcf4 to fab0f70 Compare October 21, 2022 17:25
We can't reuse the inherited method from `Product` when the case class is `AnyVal`,
because then the `productIterator$extension` would be missing from the companion.
This restores binary compatibility with Scala 2.13.8 for `AnyVal` case classes.
@lrytz
Copy link
Member

lrytz commented Nov 4, 2022

Given that this doesn't simplify case classes in bytecode (the method is still generated, just as a mixin forwarder instead of a synthethic case class member), and it doesn't simplify the compiler either, I think this change is not worh the (probably small) risk. Thanks @joroKr21!

@lrytz lrytz closed this Nov 4, 2022
@joroKr21 joroKr21 deleted the product-iter branch November 4, 2022 15:40
@SethTisue SethTisue removed this from the 2.13.11 milestone Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants