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

product-sequence-matches interferes when only sequence-match is applicable #19221

Closed
SrTobi opened this issue Dec 7, 2023 · 0 comments · Fixed by #19260
Closed

product-sequence-matches interferes when only sequence-match is applicable #19221

SrTobi opened this issue Dec 7, 2023 · 0 comments · Fixed by #19260

Comments

@SrTobi
Copy link
Contributor

SrTobi commented Dec 7, 2023

Compiler version

3.3.1

Minimized code

object Test:
  class Custom extends scala.Product1[String]:
    def length: Int = ???
    def apply(i: Int): Boolean = ???
    def drop(n: Int): scala.Seq[Boolean] = ???
    def toSeq: scala.Seq[Boolean] = ???

    def canEqual(that: Any): Boolean = ???

    val _1: String = ???
    val _2: String = ???
    val _3: Seq[String] = ???

  object A:
    def unapplySeq(i: Int): Custom = ???

  val A(a, rest*) = 1

Output

this case is unreachable since type String is not a subclass of trait Seq
  val A(a, rest*) = 1

Expectation

It should compile and A(a, rest*) should be a sequence-match.

The specification states that sequence-matches have higher priority than product-sequence-matches, but this seems not to be correctly implemented

Note that the code compiles as expected if any of the _X fields is removed

@SrTobi SrTobi added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 7, 2023
@mbovel mbovel added area:pattern-matching and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 11, 2023
@dwijnand dwijnand linked a pull request Dec 13, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants