aboutsummaryrefslogtreecommitdiff
path: root/tests/neg/hk-bounds.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-07-14 23:13:09 +0200
committerMartin Odersky <odersky@gmail.com>2016-07-14 23:13:09 +0200
commita737b47a92fe414a5e7f07bae171878c81bf9f45 (patch)
treed5b2b84cacc11b2d533b0230a5da5d79ccbd8bf7 /tests/neg/hk-bounds.scala
parent82fc27f0c2c800de786b54110cfd8627b043fe6d (diff)
downloaddotty-a737b47a92fe414a5e7f07bae171878c81bf9f45.tar.gz
dotty-a737b47a92fe414a5e7f07bae171878c81bf9f45.tar.bz2
dotty-a737b47a92fe414a5e7f07bae171878c81bf9f45.zip
Add test case for hk bounds checking
Diffstat (limited to 'tests/neg/hk-bounds.scala')
-rw-r--r--tests/neg/hk-bounds.scala23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/neg/hk-bounds.scala b/tests/neg/hk-bounds.scala
new file mode 100644
index 000000000..80c8cfaa8
--- /dev/null
+++ b/tests/neg/hk-bounds.scala
@@ -0,0 +1,23 @@
+class Foo[A]
+class Bar[B]
+class Baz[C] extends Bar[C]
+
+object Test1 {
+ type Alias[F[X] <: Foo[X]] = F[Int]
+
+ val x: Alias[Bar] = new Bar[Int] // error: Type argument [X0] -> Bar[X0] does not conform to upper bound [X0] -> Foo[X0]
+
+ def foo[F[X] <: Foo[X]] = ()
+ foo[Bar] // error: Type argument [X0] -> Bar[X0] does not conform to upper bound [X0] -> Foo[X0]
+
+ def bar[B[X] >: Bar[X]] = ()
+ bar[Bar] // ok
+ bar[Baz] // // error: Type argument [X0] -> Baz[X0] does not conform to lower bound [X0] -> Bar[X0]
+ bar[Foo] // error: Type argument [X0] -> Foo[X0] does not conform to lower bound [X0] -> Bar[X0]
+
+ def baz[B[X] >: Baz[X]] = ()
+ baz[Bar] //ok
+ baz[Baz] //ok
+ baz[Foo] // error: Type argument [X0] -> Foo[X0] does not conform to lower bound [X0] -> Baz[X0]
+
+}