aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-07-09 19:46:39 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-09 21:27:14 +0200
commit490cc5ff508b45e5b32bced5f4e760258450358e (patch)
tree81bfdfe51d2ce52c890d4e6dc4092737ee8845eb /tests
parent17191782afa2cdc2f0b018ecf4429ba18eeafc73 (diff)
downloaddotty-490cc5ff508b45e5b32bced5f4e760258450358e.tar.gz
dotty-490cc5ff508b45e5b32bced5f4e760258450358e.tar.bz2
dotty-490cc5ff508b45e5b32bced5f4e760258450358e.zip
Fix 1365: Fix bindings in patterns
We need to compare pattern types with expected types in order to derive knowledge about pattern-bound variables. This is done use the mechanism of gadt bounds.
Diffstat (limited to 'tests')
-rw-r--r--tests/pos/i1365.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/pos/i1365.scala b/tests/pos/i1365.scala
new file mode 100644
index 000000000..e7d47da4b
--- /dev/null
+++ b/tests/pos/i1365.scala
@@ -0,0 +1,13 @@
+import scala.collection.mutable.ArrayBuffer
+
+trait Message[M]
+class Script[S] extends ArrayBuffer[Message[S]] with Message[S]
+
+class Test[A] {
+ def f(cmd: Message[A]): Unit = cmd match {
+ case s: Script[_] => s.iterator.foreach(x => f(x))
+ }
+ def g(cmd: Message[A]): Unit = cmd match {
+ case s: Script[z] => s.iterator.foreach(x => g(x))
+ }
+}