Skip to content

Commit a737b47

Browse files
committed
Add test case for hk bounds checking
1 parent 82fc27f commit a737b47

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/neg/hk-bounds.scala

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Foo[A]
2+
class Bar[B]
3+
class Baz[C] extends Bar[C]
4+
5+
object Test1 {
6+
type Alias[F[X] <: Foo[X]] = F[Int]
7+
8+
val x: Alias[Bar] = new Bar[Int] // error: Type argument [X0] -> Bar[X0] does not conform to upper bound [X0] -> Foo[X0]
9+
10+
def foo[F[X] <: Foo[X]] = ()
11+
foo[Bar] // error: Type argument [X0] -> Bar[X0] does not conform to upper bound [X0] -> Foo[X0]
12+
13+
def bar[B[X] >: Bar[X]] = ()
14+
bar[Bar] // ok
15+
bar[Baz] // // error: Type argument [X0] -> Baz[X0] does not conform to lower bound [X0] -> Bar[X0]
16+
bar[Foo] // error: Type argument [X0] -> Foo[X0] does not conform to lower bound [X0] -> Bar[X0]
17+
18+
def baz[B[X] >: Baz[X]] = ()
19+
baz[Bar] //ok
20+
baz[Baz] //ok
21+
baz[Foo] // error: Type argument [X0] -> Foo[X0] does not conform to lower bound [X0] -> Baz[X0]
22+
23+
}

0 commit comments

Comments
 (0)