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
Conversation
There was a problem hiding this 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.
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 |
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. |
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. |
6c3fcf4
to
fab0f70
Compare
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.
fab0f70
to
80f37f9
Compare
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! |
We can't reuse the inherited method from
Product
when the case class isAnyVal
, because then theproductIterator$extension
would be missing from the companion. This restores binary compatibility with Scala 2.13.8 forAnyVal
case classes.Alternative to #10155