summaryrefslogtreecommitdiff
path: root/test/pending/neg
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-08-17 09:58:54 -0700
committerPaul Phillips <paulp@improving.org>2013-08-17 10:58:14 -0700
commit1cd7a9e840158dab17a3aafc0ce849605706a561 (patch)
tree3777a5c8bdfe0edcdcd45aa453d28704242a8702 /test/pending/neg
parent8f05647ca53da781b420be0723faf1cdbf14b2ff (diff)
downloadscala-1cd7a9e840158dab17a3aafc0ce849605706a561.tar.gz
scala-1cd7a9e840158dab17a3aafc0ce849605706a561.tar.bz2
scala-1cd7a9e840158dab17a3aafc0ce849605706a561.zip
New tests for name-based pattern matcher.
Diffstat (limited to 'test/pending/neg')
-rw-r--r--test/pending/neg/t6680a.scala13
-rw-r--r--test/pending/neg/t6680b.check6
-rw-r--r--test/pending/neg/t6680b.scala10
-rw-r--r--test/pending/neg/t6680c.scala17
4 files changed, 46 insertions, 0 deletions
diff --git a/test/pending/neg/t6680a.scala b/test/pending/neg/t6680a.scala
new file mode 100644
index 0000000000..745334b1cd
--- /dev/null
+++ b/test/pending/neg/t6680a.scala
@@ -0,0 +1,13 @@
+case class Cell[A](var x: A)
+object Test {
+ def f1(x: Any) = x match { case y @ Cell(_) => y } // Inferred type is Cell[Any]
+ // def f2(x: Cell[_]) = x match { case y @ Cell(_) => y } // Inferred type is Cell[_]
+ // def f3[A](x: Cell[A]) = x match { case y @ Cell(_) => y } // Inferred type is Cell[A]
+
+ def main(args: Array[String]): Unit = {
+ // val x = new Cell(1)
+ // val y = f1(x)
+ // y.x = "abc"
+ // println(x.x + 1)
+ }
+} \ No newline at end of file
diff --git a/test/pending/neg/t6680b.check b/test/pending/neg/t6680b.check
new file mode 100644
index 0000000000..a16812d91d
--- /dev/null
+++ b/test/pending/neg/t6680b.check
@@ -0,0 +1,6 @@
+t6680b.scala:8: error: type mismatch;
+ found : String("not what you\'d expect")
+ required: ?Hidden1 where type ?Hidden1 (this is a GADT skolem)
+ case Concrete(f) => f("not what you'd expect")
+ ^
+one error found
diff --git a/test/pending/neg/t6680b.scala b/test/pending/neg/t6680b.scala
new file mode 100644
index 0000000000..e9f6468315
--- /dev/null
+++ b/test/pending/neg/t6680b.scala
@@ -0,0 +1,10 @@
+trait Super[+A]
+// `Hidden` must occur in both variance positions (covariant/contravariant) for the sneakiness to work
+// this way type inference will infer Any for `Hidden` and `A` in the pattern below
+case class Concrete[Hidden, +A](havoc: Hidden => Hidden) extends Super[A]
+
+object Test extends App {
+ (Concrete((x: Int) => x): Super[Any]) match {
+ case Concrete(f) => f("not what you'd expect")
+ }
+} \ No newline at end of file
diff --git a/test/pending/neg/t6680c.scala b/test/pending/neg/t6680c.scala
new file mode 100644
index 0000000000..f69663a71b
--- /dev/null
+++ b/test/pending/neg/t6680c.scala
@@ -0,0 +1,17 @@
+package s
+
+trait Stream[+A]
+case class Unfold[S,+A](s: S, f: S => Option[(A,S)]) extends Stream[A]
+
+object Stream {
+ def fromList[A](a: List[A]): Stream[A] =
+ Unfold(a, (l:List[A]) => l.headOption.map((_,l.tail)))
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val res = Stream.fromList(List(1,2,3,4))
+
+ res match { case Unfold(s, f) => f("a string!") }
+ }
+}