diff options
Diffstat (limited to 'test/pending')
-rw-r--r-- | test/pending/neg/t6680a.scala | 13 | ||||
-rw-r--r-- | test/pending/neg/t6680b.check | 6 | ||||
-rw-r--r-- | test/pending/neg/t6680b.scala | 10 | ||||
-rw-r--r-- | test/pending/neg/t6680c.scala | 17 |
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!") } + } +} |