-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Tuple.fromProduct #6514
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
Add Tuple.fromProduct #6514
Conversation
b802640
to
d7aa95e
Compare
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.
LGTM
tests/run/Tuple-fromProduct.scala
Outdated
@@ -0,0 +1,47 @@ | |||
import scala.reflect.ClassTag |
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.
Minor: this is not required, I guess
// FIXME ProductN for N > 22 does not extends product | ||
// testProduct((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23)) | ||
// testProduct((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24)) | ||
// testProduct((1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)) |
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.
This seems to be an oversight, I made the following changes, it seems to work:
-sealed class *:[+H, +T <: Tuple] extends NonEmptyTuple
+sealed abstract class *:[+H, +T <: Tuple] extends NonEmptyTuple with Product
/cc: @odersky
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.
I'm looking into it as well. But this might not be what we want. The methods on product should also be specialized. For example productArity
should do exactly the same as size
.
Then there is the same issue for Tuple
in general, not only non empty tuples. There the additional complete cation is that Unit is not a product.
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.
I think Unit
probably should be a Product
:-)
Based on #6510