summaryrefslogtreecommitdiff
path: root/test/files/run/bug3530.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-04-23 22:04:36 +0000
committerPaul Phillips <paulp@improving.org>2011-04-23 22:04:36 +0000
commit63c7c9d857568879bfda146dd31bfc4ee38cb9fb (patch)
treef11372dc3d38c1eb0a327b33afb9fb25a0a7a658 /test/files/run/bug3530.scala
parent21121ff62ea72523ed5ea6a906b2ce42e9e47f69 (diff)
downloadscala-63c7c9d857568879bfda146dd31bfc4ee38cb9fb.tar.gz
scala-63c7c9d857568879bfda146dd31bfc4ee38cb9fb.tar.bz2
scala-63c7c9d857568879bfda146dd31bfc4ee38cb9fb.zip
Working my way through pattern matcher sequence...
Working my way through pattern matcher sequence issues mostly caused by the special handling of Lists. Also deleting all kinds of useless or almost useless code which is presently only clutter. Closes #2756, #2800, #3050, #3530, #3972, no review.
Diffstat (limited to 'test/files/run/bug3530.scala')
-rw-r--r--test/files/run/bug3530.scala36
1 files changed, 31 insertions, 5 deletions
diff --git a/test/files/run/bug3530.scala b/test/files/run/bug3530.scala
index f2c0034691..f6f7fb4229 100644
--- a/test/files/run/bug3530.scala
+++ b/test/files/run/bug3530.scala
@@ -1,9 +1,35 @@
object Test {
+ def f(x: Any) = println(x match {
+ case List(_, _) => "two"
+ case List(_, _, _) => "three"
+ case xs @ List(_*) => "list: " + xs.length
+ case _ => "not a list"
+ })
+
+ def f2[T](x: List[T]) = println(x match {
+ case List(_, _) => "two"
+ case List(_, _, _) => "three"
+ case List(xs @ _*) => "list: " + xs.length
+ // bug: the default case is marked unreachable
+ // case _ => "not a list"
+ })
+
def main(args: Array[String]) {
- val list = List(1,2,3)
- list match {
- case List(_, _) => println("List with two elements")
- case List(_*) => println("Some List")
- }
+ f(List(1, 2))
+ f(List('a', 'b', 'c'))
+ f(List('a', 'b', 'c', 'd'))
+ f(Nil)
+ f(List(1,2,3,4,5))
+ f(null)
+
+ println
+
+ f2(List(1, 2))
+ f2(List('a', 'b', 'c'))
+ f2(List('a', 'b', 'c', 'd'))
+ f2(Nil)
+ f2(List(1,2,3,4,5))
+ // bug: this NPEs on xs.length
+ // f2(null)
}
} \ No newline at end of file