aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/variances.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/neg/variances.scala')
-rw-r--r--tests/neg/variances.scala15
1 files changed, 15 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