summaryrefslogtreecommitdiff
path: root/test/files/neg/t6680a.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-10-01 20:28:48 -0700
committerPaul Phillips <paulp@improving.org>2013-10-01 20:41:41 -0700
commit5708e9d73ba01c286d7155606b72caeab914face (patch)
tree422ca2158adb3392aa3826ea9ab9cae4a379f5ce /test/files/neg/t6680a.scala
parent95d5554b9a263e3eb060c181463234f3e79864ab (diff)
downloadscala-5708e9d73ba01c286d7155606b72caeab914face.tar.gz
scala-5708e9d73ba01c286d7155606b72caeab914face.tar.bz2
scala-5708e9d73ba01c286d7155606b72caeab914face.zip
SI-6680 unsoundness in gadt typing.
Introduces -Xstrict-inference to deal with the significant gap between soundness and what presently compiles. I'm hopeful that it's TOO strict, because it finds e.g. 75 errors compiling immutable/IntMap.scala, but it might be that bad.
Diffstat (limited to 'test/files/neg/t6680a.scala')
-rw-r--r--test/files/neg/t6680a.scala18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/files/neg/t6680a.scala b/test/files/neg/t6680a.scala
new file mode 100644
index 0000000000..93b796438f
--- /dev/null
+++ b/test/files/neg/t6680a.scala
@@ -0,0 +1,18 @@
+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)
+ }
+}
+
+// The tweetable variation
+object Tweet {
+ case class C[A](f:A=>A);def f(x:Any)=x match { case C(f)=>f("") };f(C[Int](x=>x))
+}