Skip to content

Commit

Permalink
Add fixed GADT exhaustivity test cases (#16169)
Browse files Browse the repository at this point in the history
  • Loading branch information
abgruszecki authored Oct 18, 2022
2 parents 3636ee6 + c406ace commit bbeb20d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/pos/i7424.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// scalac: -Werror
object GADT {
import =:=._

enum =:=[A, B] {
case Refl[C]() extends (C =:= C)
}

def unwrap[A,B](opt: Option[A])(using ev: A =:= Option[B]): Option[B] = ev match {
case Refl() => opt.flatMap(identity[Option[B]])
}
}
12 changes: 12 additions & 0 deletions tests/pos/i7424b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// scalac: -Werror
object GADT {
import =:=._

enum =:=[A, B] {
case Refl[C]() extends (C =:= C)
}

def unwrap[A,B](opt: Option[A])(using ev: A =:= Option[B]): Option[B] = ev match {
case _: Refl[?] => opt.flatMap(identity[Option[B]])
}
}
8 changes: 8 additions & 0 deletions tests/pos/i7424c.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// scalac: -Werror
object Main extends App:
enum Extends[A, B]:
case Ev[B, A <: B]() extends (A Extends B)

def cast(a: A): B = this match {
case Extends.Ev() => a
}

0 comments on commit bbeb20d

Please sign in to comment.