File tree Expand file tree Collapse file tree 3 files changed +29
-7
lines changed
compiler/src/dotty/tools/dotc/transform/patmat Expand file tree Collapse file tree 3 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -709,7 +709,7 @@ object SpaceEngine {
709709 else NoType
710710 }.filter(_.exists)
711711 parts
712- case tref : TypeRef if tref.symbol.isAbstractOrAliasType && ! tref.info.hiBound.isNothingType =>
712+ case tref : TypeRef if tref.isUpperBoundedAbstract =>
713713 rec(tref.info.hiBound, mixins)
714714 case _ => ListOfNoType
715715 end rec
@@ -726,6 +726,10 @@ object SpaceEngine {
726726 && ! cls.hasAnonymousChild // can't name anonymous classes as counter-examples
727727 && cls.children.nonEmpty // can't decompose without children
728728
729+ extension (tref : TypeRef )
730+ def isUpperBoundedAbstract (using Context ): Boolean =
731+ tref.symbol.isAbstractOrAliasType && ! tref.info.hiBound.isNothingType
732+
729733 val ListOfNoType = List (NoType )
730734 val ListOfTypNoType = ListOfNoType .map(Typ (_, decomposed = true ))
731735
@@ -857,10 +861,7 @@ object SpaceEngine {
857861 classSym.is(Case ) ||
858862 (tpw.isInstanceOf [TypeRef ] && {
859863 val tref = tpw.asInstanceOf [TypeRef ]
860- if (tref.symbol.isAbstractOrAliasType && ! tref.info.hiBound.isNothingType)
861- isCheckable(tref.info.hiBound)
862- else
863- false
864+ tref.isUpperBoundedAbstract && isCheckable(tref.info.hiBound)
864865 })
865866
866867 ! sel.tpe.hasAnnotation(defn.UncheckedAnnot )
Original file line number Diff line number Diff line change 77 |
88 | longer explanation available when compiling with `-explain`
99-- [E029] Pattern Match Exhaustivity Warning: tests/warn/i23620b.scala:23:2 --------------------------------------------
10- 23 | p2 match { //warn
10+ 23 | p2 match { // warn
1111 | ^^
1212 | match may not be exhaustive.
1313 |
1414 | It would fail on pattern case: _: Bar
1515 |
1616 | longer explanation available when compiling with `-explain`
17+ -- [E029] Pattern Match Exhaustivity Warning: tests/warn/i23620b.scala:37:2 --------------------------------------------
18+ 37 | x match // warn
19+ | ^
20+ | match may not be exhaustive.
21+ |
22+ | It would fail on pattern case: B
23+ |
24+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change @@ -20,6 +20,19 @@ object OnlyFoo:
2020 p match // warn
2121 case _ : Foo => println(" foo" )
2222
23- p2 match { // warn
23+ p2 match { // warn
2424 case _ : Foo => println(" foo" )
2525 }
26+
27+ sealed trait S
28+ trait Z
29+
30+ case object A extends S , Z
31+ case object B extends S , Z
32+
33+ trait HasT :
34+ type T <: S & Z
35+
36+ def nonExhaustive (h : HasT , x : h.T ) =
37+ x match // warn
38+ case A => ()
You can’t perform that action at this time.
0 commit comments