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 @@ -708,7 +708,7 @@ object SpaceEngine {
708708 else NoType
709709 }.filter(_.exists)
710710 parts
711- case tref : TypeRef if tref.symbol.isAbstractOrAliasType && ! tref.info.hiBound.isNothingType =>
711+ case tref : TypeRef if tref.isUpperBoundedAbstract =>
712712 rec(tref.info.hiBound, mixins)
713713 case _ => ListOfNoType
714714 end rec
@@ -727,6 +727,10 @@ object SpaceEngine {
727727 && cls.children.nonEmpty // can't decompose without children
728728 && ! sym.isOpaqueAlias // can't instantiate subclasses to conform to an opaque type (i19275)
729729
730+ extension (tref : TypeRef )
731+ def isUpperBoundedAbstract (using Context ): Boolean =
732+ tref.symbol.isAbstractOrAliasType && ! tref.info.hiBound.isNothingType
733+
730734 val ListOfNoType = List (NoType )
731735 val ListOfTypNoType = ListOfNoType .map(Typ (_, decomposed = true ))
732736
@@ -858,10 +862,7 @@ object SpaceEngine {
858862 classSym.is(Case ) ||
859863 (tpw.isInstanceOf [TypeRef ] && {
860864 val tref = tpw.asInstanceOf [TypeRef ]
861- if (tref.symbol.isAbstractOrAliasType && ! tref.info.hiBound.isNothingType)
862- isCheckable(tref.info.hiBound)
863- else
864- false
865+ tref.isUpperBoundedAbstract && isCheckable(tref.info.hiBound)
865866 })
866867
867868 ! 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