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

unapply cannot return generic tuples #13969

Closed
nicolasstucki opened this issue Nov 17, 2021 · 3 comments
Closed

unapply cannot return generic tuples #13969

nicolasstucki opened this issue Nov 17, 2021 · 3 comments

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.1.0

Minimized example

object Bar:
  def unapply(x: Any): Int *: Int *: EmptyTuple = ??? // Works it returns a `Tuple2[Int, Int]`

def test =
  "" match
    case Bar(a, b) =>

Output

10 |    case Bar(a, b) =>
   |         ^^^^^^^^^
   |         Wrong number of argument patterns for Bar; expected: ()

Expectation

Should be supported.

@dwijnand
Copy link
Member

This doesn't work because Tuple's product arity is 0 ("expected: ()"). I guess we need to teach productArity to walk the type to count the arity.

@nicolasstucki
Copy link
Contributor Author

It seems that in the example of #13968 we do calculate the arity correctly. We should see how it is handled there and why it was not done here.

@dwijnand
Copy link
Member

Duplicate of #11008

@dwijnand dwijnand marked this as a duplicate of #11008 Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants