aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-03-31 11:50:49 +0200
committerMartin Odersky <odersky@gmail.com>2016-03-31 11:50:49 +0200
commit7871236ec02d8fbf4cc16c329c737d9e2ee682f3 (patch)
treef62d5b05f495d2b89b47643afa49c02f2c78aaca
parent5bd08d437c1365bd8a81cb1b6b9801b443fde96b (diff)
downloaddotty-7871236ec02d8fbf4cc16c329c737d9e2ee682f3.tar.gz
dotty-7871236ec02d8fbf4cc16c329c737d9e2ee682f3.tar.bz2
dotty-7871236ec02d8fbf4cc16c329c737d9e2ee682f3.zip
merge variances and Variances
-rw-r--r--tests/neg/variances.scala15
-rw-r--r--tests/pos/variances.scala15
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/neg/variances.scala b/tests/neg/variances.scala
index 71ee504bc..d732bb6db 100644
--- a/tests/neg/variances.scala
+++ b/tests/neg/variances.scala
@@ -41,4 +41,19 @@ object Test2 extends App {
}
+trait HasY { type Y }
+
+// These are neg-tests corresponding to the pos-test Variances.scala
+// where all the variance annotations have been inverted.
+trait Foo1[+X] { def bar[Y <: X](y: Y) = y } // error
+trait Foo2[+X] { def bar(x: HasY { type Y <: X })(y: x.Y) = y } // error
+trait Foo3[-X] { def bar[Y >: X](y: Y) = y } // error
+trait Foo4[-X] { def bar(x: HasY { type Y >: X })(y: x.Y) = y } // error
+
+// These are neg-tests corresponding to the pos-test Variances.scala
+// where all the bounds have been flipped.
+trait Foo5[-X] { def bar[Y >: X](y: Y) = y } // error
+trait Foo6[-X] { def bar(x: HasY { type Y >: X })(y: x.Y) = y } // error
+trait Foo7[+X] { def bar[Y <: X](y: Y) = y } // error
+trait Foo8[+X] { def bar(x: HasY { type Y <: X })(y: x.Y) = y } // error
diff --git a/tests/pos/variances.scala b/tests/pos/variances.scala
index db858fd5d..7ab9fe72a 100644
--- a/tests/pos/variances.scala
+++ b/tests/pos/variances.scala
@@ -1,3 +1,18 @@
trait C[+T <: C[T, U], -U <: C[T, U]] {
}
+trait HasY { type Y }
+
+// This works in scalac.
+trait Foo1[-X] { def bar[Y <: X](y: Y) = y }
+
+// A variant of Foo1 using a dependent method type (doesn't work using
+// scalac)
+trait Foo2[-X] { def bar(x: HasY { type Y <: X })(y: x.Y) = y }
+
+// This works in scalac.
+trait Foo3[+X] { def bar[Y >: X](y: Y) = y }
+
+// A variant of Foo3 using a dependent method type (doesn't work
+// using scalac)
+trait Foo4[+X] { def bar(x: HasY { type Y >: X })(y: x.Y) = y }