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

Fix 12919 - summon anonymous mirror when companion is a case object #14986

Merged
merged 3 commits into from
May 5, 2022

Conversation

bishabosha
Copy link
Member

@bishabosha bishabosha commented Apr 20, 2022

closes #12919
closes #15101

There were two alternatives to solve this:

  • (first commit) use singleton proxy to summon a mirror for a case object when its companion is a sum/product, always cache mirror of case class / sum type in its companion.
  • (second commit) make the sum/product mirror anonymous when their companion is a case object

The first option will result in less code generation, however it will change the parent types of the companion from Mirror.Singleton to either Mirror.Product or Mirror.Sum (and change signatures of fromProduct or ordinal in the companion), the second option will result in more code generation, but will preserve the signatures of the companion in bytecode for existing code.

@smarter
Copy link
Member

smarter commented Apr 21, 2022

I'm not very familiar with the mechanisms of mirror generation, perhaps @dwijnand could review this?

@bishabosha bishabosha requested review from dwijnand and removed request for smarter April 21, 2022 13:00
@bishabosha bishabosha assigned dwijnand and unassigned smarter Apr 21, 2022
@bishabosha bishabosha changed the title Fix 12919 - do not make case object a singleton mirror if companion is case class Fix 12919 - summon anonymous mirror when companion is a case object Apr 21, 2022
@Lasering
Copy link

Lasering commented May 4, 2022

It would be nice if this change would allow for this #14136 in the future.

@dwijnand dwijnand merged commit 06a8f22 into scala:main May 5, 2022
@dwijnand dwijnand deleted the fix-12919 branch May 5, 2022 08:58
@bishabosha bishabosha added the release-notes Should be mentioned in the release notes label May 9, 2022
@Kordyjan Kordyjan added this to the 3.2.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:typeclass-derivation release-notes Should be mentioned in the release notes
Projects
None yet
5 participants