aboutsummaryrefslogtreecommitdiff
path: root/tests/run/virtpatmat_unapply.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-22 16:07:23 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-22 16:07:23 +0200
commit6965b470d433f501203c4e3d77b0919f826691ba (patch)
tree413446f1af3f40bb69499a60066609af6bc38d9f /tests/run/virtpatmat_unapply.scala
parent91bb668c5f1b6e5c51dad9b373c9398521508bc3 (diff)
downloaddotty-6965b470d433f501203c4e3d77b0919f826691ba.tar.gz
dotty-6965b470d433f501203c4e3d77b0919f826691ba.tar.bz2
dotty-6965b470d433f501203c4e3d77b0919f826691ba.zip
Enable 440 run tests that pass.
Note that some of them may pass due to several bugs that interfere.
Diffstat (limited to 'tests/run/virtpatmat_unapply.scala')
-rw-r--r--tests/run/virtpatmat_unapply.scala32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/run/virtpatmat_unapply.scala b/tests/run/virtpatmat_unapply.scala
new file mode 100644
index 000000000..9915b8d92
--- /dev/null
+++ b/tests/run/virtpatmat_unapply.scala
@@ -0,0 +1,32 @@
+class IntList(val hd: Int, val tl: IntList)
+object NilIL extends IntList(0, null)
+object IntList {
+ def unapply(il: IntList): Option[(Int, IntList)] = if(il eq NilIL) None else Some(il.hd, il.tl)
+ def apply(x: Int, xs: IntList) = new IntList(x, xs)
+}
+
+object Test extends dotty.runtime.LegacyApp {
+ IntList(1, IntList(2, NilIL)) match {
+ case IntList(a1, IntList(a2, IntList(a3, y))) => println(a1 + a2 + a3)
+ case IntList(x, y) => println(x)
+ }
+
+ IntList(1, IntList(2, IntList(3, NilIL))) match {
+ case IntList(a1, IntList(a2, IntList(a3, y))) => println(a1 + a2 + a3)
+ case IntList(x, y) => println(x)
+ }
+}
+
+// ((x1: IntList) => IntList.unapply(x1).flatMap(((x4: (Int, IntList)) => IntList.unapply(x4._2).flatMap(((x5: (Int, IntList)) => IntList.unapply(x5._2).flatMap(((x6: (Int, IntList)) => implicitly[Predef.MatchingStrategy[Option]].success(Predef.println(x4._1.+(x5._1).+(x6._1))))))))).orElse(IntList.unapply(x1).flatMap(((x7: (Int, IntList)) => implicitly[scala.Predef.MatchingStrategy[Option]].success(Predef.println(x7._1))))).orElse(implicitly[scala.Predef.MatchingStrategy[Option]].fail))(IntList.apply(1, IntList.apply(2, IntList.apply(3, null))))
+
+/*
+ ((x1: IntList) =>
+ IntList.this.unapply(x1).flatMap[Int](((x4: (Int, IntList)) =>
+ IntList.this.unapply(x4._2).flatMap[Int](((x5: (Int, IntList)) =>
+ IntList.this.unapply(x5._2).flatMap[Int](((x6: (Int, IntList)) =>
+ Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).success[Int](x6._1))))))).orElse[Int](
+ IntList.this.unapply(x1).flatMap[Int](((x7: (Int, IntList)) =>
+ Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).success[Int](x7._1)))).orElse[Int](
+ Predef.this.implicitly[scala.Predef.MatchingStrategy[Option]](scala.this.Predef.OptionMatching).fail)
+ ).apply(IntList.apply(1, null))
+*/