aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-21 18:19:09 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-09-23 11:30:01 +0200
commit9b576c2c1c36003e0ca0a760c36aae028991400f (patch)
treeb5192d5492616582de12dd67a6edad69fe5121d1 /tests/neg
parent8bd14310f60c1be997a62eaba84dd49624ea2df6 (diff)
downloaddotty-9b576c2c1c36003e0ca0a760c36aae028991400f.tar.gz
dotty-9b576c2c1c36003e0ca0a760c36aae028991400f.tar.bz2
dotty-9b576c2c1c36003e0ca0a760c36aae028991400f.zip
Fix problem in unapply typing.
GADT bound resetting may only be applied when comparing <pattern type> <: <expected type>, not when comparing the other way around. The fix revealed an error in a test case (t1048) which looks like a real error. Therefore the test got moved to neg. Conflicts: src/dotty/tools/dotc/typer/Applications.scala test/dotc/tests.scala tests/disabled/t1048.scala
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/t1048.scala21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/neg/t1048.scala b/tests/neg/t1048.scala
new file mode 100644
index 000000000..4b8e78b4c
--- /dev/null
+++ b/tests/neg/t1048.scala
@@ -0,0 +1,21 @@
+trait T[U] {
+ def x: T[_ <: U]
+}
+
+object T {
+ def unapply[U](t: T[U]): Option[T[_ <: U]] = Some(t.x)
+}
+
+object Test {
+ def f[W](t: T[W]) = t match {
+ case T(T(_)) => ()
+// Gives:
+// t1048.scala:11: error: There is no best instantiation of pattern type T[Any']
+// that makes it a subtype of selector type T[_ <: W].
+// Non-variant type variable U cannot be uniquely instantiated.
+// case T(T(_)) => ()
+// ^
+// one error found
+ }
+}
+