Skip to content

Fix #4984: support name-based unapplySeq #5078

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

Merged
merged 10 commits into from
Sep 20, 2018
Prev Previous commit
Next Next commit
add neg test
  • Loading branch information
liufengyun authored and allanrenucci committed Sep 9, 2018
commit 6999ca8dc350d9f0035d161aeb8017f99d00431b
26 changes: 26 additions & 0 deletions tests/neg/i4984.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
object Array2 {
def unapplySeq(x: Array[Int]): Data = new Data

final class Data {
def isEmpty: Boolean = false
def get: Data = this
def lengthCompare(len: Int): Int = 0
def apply(i: Int): Int = 3
def drop(n: Int): scala.Seq[String] = Seq("hello")
def toSeq: scala.Seq[Int] = Seq(6, 7)
}
}

object Test {
def test1(xs: Array[Int]): Int = xs match {
case Array2(x, y) => x + y // error // error
}

def test2(xs: Array[Int]): Seq[Int] = xs match {
case Array2(x, y, xs:_*) => xs // error
}

def test3(xs: Array[Int]): Seq[Int] = xs match {
case Array2(xs:_*) => xs // error
}
}