Skip to content

Commit 9d66791

Browse files
committed
add more tests for variance handling
1 parent abbdc24 commit 9d66791

File tree

6 files changed

+60
-0
lines changed

6 files changed

+60
-0
lines changed
File renamed without changes.
File renamed without changes.

tests/patmat/i3645c.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
21: Pattern Match Exhaustivity: K3, K2

tests/patmat/i3645c.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
object App {
2+
def main(args: Array[String]): Unit = {
3+
trait FooT {
4+
type T
5+
def subst[F[_]](fa: F[T]): F[Int]
6+
}
7+
val Foo: FooT = new FooT {
8+
type T = Int
9+
10+
def subst[F[_]](fa: F[T]): F[Int] = fa
11+
}
12+
type Foo = Foo.T
13+
type Bar = Foo
14+
15+
sealed abstract class K[+A]
16+
final case object K1 extends K[Int]
17+
final case object K2 extends K[Foo]
18+
final case object K3 extends K[Bar]
19+
20+
val foo: K[Int] = Foo.subst[K](K2)
21+
def get(k: K[Int]): Unit = k match {
22+
case K1 => ()
23+
// case K2 => ()
24+
// case K3 => ()
25+
}
26+
27+
get(foo)
28+
}
29+
}

tests/patmat/i3645d.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
21: Pattern Match Exhaustivity: K3, K2

tests/patmat/i3645d.scala

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
object App {
2+
def main(args: Array[String]): Unit = {
3+
trait FooT {
4+
type T
5+
def subst[F[_]](fa: F[T]): F[Int]
6+
}
7+
val Foo: FooT = new FooT {
8+
type T = Int
9+
10+
def subst[F[_]](fa: F[T]): F[Int] = fa
11+
}
12+
type Foo = Foo.T
13+
type Bar = Foo
14+
15+
sealed abstract class K[-A]
16+
final case object K1 extends K[Int]
17+
final case object K2 extends K[Foo]
18+
final case object K3 extends K[Bar]
19+
20+
val foo: K[Int] = Foo.subst[K](K2)
21+
def get(k: K[Int]): Unit = k match {
22+
case K1 => ()
23+
// case K2 => ()
24+
// case K3 => ()
25+
}
26+
27+
get(foo)
28+
}
29+
}

0 commit comments

Comments
 (0)