summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-07-01 16:27:03 +0000
committerPaul Phillips <paulp@improving.org>2009-07-01 16:27:03 +0000
commitf535672a90db2b3314711bf23db3550391d54e7a (patch)
tree25403a5f9a27cbede583b381d825c0846035a753 /test/files/run
parent6cee8d5837b77e5a3ba18affb802fbb466f004ee (diff)
downloadscala-f535672a90db2b3314711bf23db3550391d54e7a.tar.gz
scala-f535672a90db2b3314711bf23db3550391d54e7a.tar.bz2
scala-f535672a90db2b3314711bf23db3550391d54e7a.zip
Creating case classes in preference to passing ...
Creating case classes in preference to passing around a variety of inscrutable tuples. And, fix and test case for #1697. There remain serious extractor issues which I hope to have fully diagnosed in the near future.
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/bug1697.scala19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/run/bug1697.scala b/test/files/run/bug1697.scala
new file mode 100644
index 0000000000..3f7cb467cd
--- /dev/null
+++ b/test/files/run/bug1697.scala
@@ -0,0 +1,19 @@
+class Term
+case class Num(n: Int) extends Term
+case class Add(x: Term, y: Term) extends Term
+
+object Value {
+ def unapply(term: Any): Boolean = true
+}
+
+object Test {
+ def main(args: Array[String]) {
+ val term = Add(Num(1), Add(Num(2), Num(3)))
+ val res = term match {
+ case Add(Num(x), Num(y)) => "Add(Num, Num)"
+ case Add(Value(), y) => "Add(Value, ?)"
+ case _ => "?"
+ }
+ assert(res == "Add(Value, ?)")
+ }
+} \ No newline at end of file