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

Some[(A, Seq[B])] is not a valid result type of an unapplySeq #3248

Closed
allanrenucci opened this issue Oct 4, 2017 · 2 comments
Closed

Some[(A, Seq[B])] is not a valid result type of an unapplySeq #3248

allanrenucci opened this issue Oct 4, 2017 · 2 comments

Comments

@allanrenucci
Copy link
Contributor

This code snippet fails to compile with Dotty

class Test {
  class Foo(val name: String, val children: Int *)
  object Foo {
    def unapplySeq(f: Foo) = Some((f.name, f.children))
  }

  def foo(f: Foo) = f match {
    case Foo(name, ns @ _*) => 1
  }
}
[info] Running dotty.tools.dotc.Main -d out -language:Scala2 tests/allan/Test.scala -classpath dotty-library_2.12-0.4.0-bin-SNAPSHOT-nonbootstrapped.jar
-- Error: tests/allan/Test.scala:8:12 ------------------------------------------
8 |    case Foo(name, ns: _*) => 1
  |         ^^^^^^^^^^^^^^^^^
  |Some[(String, scala.collection.Seq[Int] @Repeated)] is not a valid result type of an unapplySeq method of an extractor
@odersky
Copy link
Contributor

odersky commented Jan 4, 2018

The code snippet now compiles with #3747 if the unapplySeq definition is replaced by unapply. Furthermore, the error message for the unapplySeq version suggests that one should use an unapply instead.

odersky added a commit that referenced this issue Jan 12, 2018
Fix #3248: Handle repeated arguments in results of unapply selectors
allanrenucci added a commit to dotty-staging/scalatest that referenced this issue Apr 18, 2018
allanrenucci added a commit to dotty-staging/scalatest that referenced this issue Apr 19, 2018
@Blaisorblade
Copy link
Contributor

Blaisorblade commented Aug 27, 2018

Given that the API in #3747 can't be used if you write the return type explicitly, I'm reopening this issue.

And given that we want cross-version Tasty to exist (at least for 3.0), and Tasty can't say that a method has a version-dependent user-written name (thankfully!), it appears we must support unapplySeq at least for 3.0.

@Blaisorblade Blaisorblade reopened this Aug 27, 2018
allanrenucci added a commit to dotty-staging/dotty that referenced this issue Oct 30, 2018
Changes to `unapply` are dropped and will be reverted in the
future. scala#3248 is reopened.
allanrenucci added a commit to dotty-staging/dotty that referenced this issue Oct 30, 2018
Changes to `unapply` are dropped and will be reverted in the
future. scala#3248 is reopened.
liufengyun added a commit to dotty-staging/dotty that referenced this issue Feb 26, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Mar 5, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Mar 7, 2019
liufengyun added a commit to dotty-staging/dotty that referenced this issue Mar 7, 2019
OlivierBlanvillain added a commit that referenced this issue Mar 11, 2019
Fix #3248: support product-seq pattern
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

4 participants