summaryrefslogtreecommitdiff
path: root/test/files/pos
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/pos
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/pos')
-rw-r--r--test/files/pos/gadts2.scala2
-rw-r--r--test/files/pos/pattern-typing.scala29
2 files changed, 30 insertions, 1 deletions
diff --git a/test/files/pos/gadts2.scala b/test/files/pos/gadts2.scala
index fc2a7e4333..d77c8a7ba4 100644
--- a/test/files/pos/gadts2.scala
+++ b/test/files/pos/gadts2.scala
@@ -4,7 +4,7 @@ object Test {
case class MyInt(n: Int) extends Number
case class MyDouble(d: Double) extends Number
- trait Term[+a]
+ trait Term[a]
case class Cell[a](var x: a) extends Term[a]
final case class NumTerm(val n: Number) extends Term[Number]
diff --git a/test/files/pos/pattern-typing.scala b/test/files/pos/pattern-typing.scala
new file mode 100644
index 0000000000..7286cc38af
--- /dev/null
+++ b/test/files/pos/pattern-typing.scala
@@ -0,0 +1,29 @@
+import scala.language.higherKinds
+
+trait Bound[B]
+
+package p1 {
+ case class Sub[B <: Bound[B]](p: B)
+ object Test {
+ def g[A](x: Bound[A]) = ()
+ def f(x: Any) = x match { case Sub(p) => g(p) }
+ }
+}
+
+package p2 {
+ trait Traversable[+A] { def head: A = ??? }
+ trait Seq[+A] extends Traversable[A] { def length: Int = ??? }
+
+ case class SubHK[B <: Bound[B], CC[X] <: Traversable[X]](xs: CC[B])
+ class MyBound extends Bound[MyBound]
+ class MySeq extends Seq[MyBound]
+
+ object Test {
+ def g[B](x: Bound[B]) = ()
+
+ def f1(x: Any) = x match { case SubHK(xs) => xs }
+ def f2[B <: Bound[B], CC[X] <: Traversable[X]](sub: SubHK[B, CC]): CC[B] = sub match { case SubHK(xs) => xs }
+ def f3 = g(f1(SubHK(new MySeq)).head)
+ def f4 = g(f2(SubHK(new MySeq)).head)
+ }
+}