aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/hk-bounds.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-07-15 10:30:30 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-15 10:30:30 +0200
commit894c9fbf247765041fc32788c78b85f1b2b2a191 (patch)
treeaa918254e5b9869e10af3e967f980fd458e4c309 /tests/neg/hk-bounds.scala
parenta737b47a92fe414a5e7f07bae171878c81bf9f45 (diff)
downloaddotty-894c9fbf247765041fc32788c78b85f1b2b2a191.tar.gz
dotty-894c9fbf247765041fc32788c78b85f1b2b2a191.tar.bz2
dotty-894c9fbf247765041fc32788c78b85f1b2b2a191.zip
Bounds of type lambdas compare contravariantly
Enable checking of bounds when comparing type lambdas. This invalidates a pattern used in t2994 and potentially other code, where a bound [X] -> Any is used as a template that is a legal supertype of all other bounds. The old behavior is still available under language:Scala2.
Diffstat (limited to 'tests/neg/hk-bounds.scala')
-rw-r--r--tests/neg/hk-bounds.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/neg/hk-bounds.scala b/tests/neg/hk-bounds.scala
index 80c8cfaa8..db6712d72 100644
--- a/tests/neg/hk-bounds.scala
+++ b/tests/neg/hk-bounds.scala
@@ -21,3 +21,11 @@ object Test1 {
baz[Foo] // error: Type argument [X0] -> Foo[X0] does not conform to lower bound [X0] -> Baz[X0]
}
+object Test2 {
+ type Alias[F[X] <: Foo[X]] = F[Int]
+
+ def foo[M[_[_]], A[_]]: M[A] = null.asInstanceOf[M[A]]
+
+ val x = foo[Alias, Bar] // error: Type argument Test2.Alias does not conform to upper bound [X0 <: [X0] -> Any] -> Any
+
+}