-
Notifications
You must be signed in to change notification settings - Fork 1.1k
How to support Mirrors for Generic Tuples arity +22 #15398
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
Comments
The |
I believe the integers should start at 0, to match the values we can pass to the |
good catch! I did too much copy pasting :) (I fixed it now) |
Do we really need labels for tuples? We could just have |
We should also make sure that #15399 works for large tuples. |
should summoning mirror for large tuples be experimental? |
Probably a good idea to have them experimental to start with. |
With NamedTuples in Scala 3.7.0 one summon Mirrors for
So
and
Are now part of the behavior Mirror for As a user this makes the current limit of 22 element mirror for Tuples feel very arbitrary. But maybe it will be easier to relax now? |
its really a case of removing the explicit special case in Synthesizer.scala, so PR welcome |
Uh oh!
There was an error while loading. Please reload this page.
Since #15250 we can now synthesize mirrors for generic tuple types if they have arity <= 22, we can do this because we pretend the mirror was for one of the equivalent
scala.Tuple<N>
classes.We can't do that for TupleXXL however as it has no accessor methods, and supporting them by creating fake accessor names would break the assumption that
MirroredElemLabels
corresponds to field accessors. Look at the example below:Compiler version
3.2.0-RC1-bin-20220606-cec9aa3-NIGHTLY
Minimized example
Output
Expectation
we should be able to support generic tuples when arity is above 22. But the path to getting there would need some planning.
I propose that we could reinterpret
MirroredElemLabels
as a tuple of literal integer types for larger generic tuples, as there is currently no static constraint preventing this. e.g.Another alternative would be to add a new subtype of mirror:
Mirror.Tuple
, (probably also necessary to make explicit that theMirroredLabel
no longer corresponds to a class name) and optionally a newMirror.TupleOf[x *: y *: z *: EmptyTuple]
summoner?Either way the elem labels only act as unique identifiers, rather than having any runtime impact (and no you should not use the labels to access fields with java reflection, just use
productIterator
.)The text was updated successfully, but these errors were encountered: