diff options
author | Paul Phillips <paulp@improving.org> | 2013-10-01 20:28:48 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-10-01 20:41:41 -0700 |
commit | 5708e9d73ba01c286d7155606b72caeab914face (patch) | |
tree | 422ca2158adb3392aa3826ea9ab9cae4a379f5ce /test/files/neg/gadts2-strict.scala | |
parent | 95d5554b9a263e3eb060c181463234f3e79864ab (diff) | |
download | scala-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/gadts2-strict.scala')
-rw-r--r-- | test/files/neg/gadts2-strict.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/files/neg/gadts2-strict.scala b/test/files/neg/gadts2-strict.scala new file mode 100644 index 0000000000..54978b7712 --- /dev/null +++ b/test/files/neg/gadts2-strict.scala @@ -0,0 +1,26 @@ +// A copy of pos/gadts2, which must fail under -Xstrict-inference. +object Test { + + abstract class Number + case class MyInt(n: Int) extends Number + case class MyDouble(d: Double) extends Number + + trait Term[a] + case class Cell[a](var x: a) extends Term[a] + final case class NumTerm(val n: Number) extends Term[Number] + + def f[a](t: Term[a], c: Cell[a]) { + t match { + case NumTerm(n) => c.x = MyDouble(1.0) + } + } + + val x: Term[Number] = NumTerm(MyInt(5)) + + def main(args: Array[String]) { + val cell = Cell[Number](MyInt(6)) + Console.println(cell) + f[Number](new NumTerm(MyInt(5)), cell) + Console.println(cell) + } +} |