From a737b47a92fe414a5e7f07bae171878c81bf9f45 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 14 Jul 2016 23:13:09 +0200 Subject: Add test case for hk bounds checking --- tests/neg/hk-bounds.scala | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/neg/hk-bounds.scala (limited to 'tests/neg') 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] + +} -- cgit v1.2.3