Skip to content

Commit

Permalink
Use the upper bound of type skolems to enumerate subtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Feb 1, 2021
1 parent 99a6820 commit 0733455
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Expand Up @@ -164,6 +164,8 @@ trait TreeAndTypeAnalysis extends Debugging {
case sym if sym.isCase =>
List(List(tp))

case sym if sym.isTypeSkolem => enumerateSubtypes(sym.info.upperBound, grouped) // pos/t12277

case sym =>
debug.patmat("enum unsealed "+ ((tp, sym, sym.isSealed, isPrimitiveValueClass(sym))))
Nil
Expand Down
12 changes: 12 additions & 0 deletions test/files/pos/t12277.scala
@@ -0,0 +1,12 @@
// scalac: -Xlint:strict-unsealed-patmat -Werror
sealed trait A
final case class B() extends A
final case class C() extends A

object x extends App {

def matcher[A1 <: A](a1: A1) = a1 match {
case x @ (_: B | _: C) => println("B")
}

}

0 comments on commit 0733455

Please sign in to comment.