aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/Patterns.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-17 17:49:35 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-17 18:08:38 +0200
commitd6d7c2529e51d3abc9be6a1ab7601cf3c598d732 (patch)
tree2951c97123e4c8794975e2f477c046a11b75de92 /tests/pos/Patterns.scala
parentf75432fb31807938db2e9f78980fa574f88cd535 (diff)
downloaddotty-d6d7c2529e51d3abc9be6a1ab7601cf3c598d732.tar.gz
dotty-d6d7c2529e51d3abc9be6a1ab7601cf3c598d732.tar.bz2
dotty-d6d7c2529e51d3abc9be6a1ab7601cf3c598d732.zip
More complicated tests for patmat
Diffstat (limited to 'tests/pos/Patterns.scala')
-rw-r--r--tests/pos/Patterns.scala42
1 files changed, 30 insertions, 12 deletions
diff --git a/tests/pos/Patterns.scala b/tests/pos/Patterns.scala
index 7bb5005f9..9a3811b3b 100644
--- a/tests/pos/Patterns.scala
+++ b/tests/pos/Patterns.scala
@@ -1,22 +1,40 @@
+import dotty.tools.dotc.core.Types._
+
object Patterns {
- /*('1', "1") match {
+ val d: Object = null
+ private def rebase(tp: NamedType): Type = {
+ def rebaseFrom(prefix: Type): Type = ???
+ tp.prefix match {
+ case RefinedThis(rt) => rebaseFrom(rt)
+ case pre: ThisType => rebaseFrom(pre)
+ case _ => tp
+ }
+ }
+ d match {
+ case WildcardType(bounds: TypeBounds) =>
+ bounds.variance
+ }
+
+ ('1', "1") match {
case (digit, str) => true
case _ => false
}
-*/
+
+
+ def foo2(x: AnyRef) = x match { case x: Function0[Any] => x() }
object Breakdown {
def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there"))
}
object Test2 {
42 match {
- case Breakdown("") => // needed to trigger bug
- case Breakdown("foo") => // needed to trigger bug
- case Breakdown("", who) => println ("hello " + who)
+ case a@Breakdown(f@"") => // needed to trigger bug
+ case b@Breakdown(d@"foo") => // needed to trigger bug
+ case c@Breakdown(e@"", who) => println ("hello " + who)
}
}
- /*val names = List("a", "b", "c")
+ val names = List("a", "b", "c")
object SeqExtractors {
val y = names match {
case List(x, z) => x
@@ -53,10 +71,10 @@ object Patterns {
final def sameLength[T](xs: List[T], ys: List[T]): Boolean = xs match {
case _ :: xs1 => xs1.isEmpty
- // ys match {
- // case _ :: ys1 => sameLength(xs1, ys1)
- // case _ => false
- // }
- //case _ => ys.isEmpty
- }*/
+ ys match {
+ case _ :: ys1 => sameLength(xs1, ys1)
+ case _ => false
+ }
+ case _ => ys.isEmpty
+ }
}