File tree Expand file tree Collapse file tree 4 files changed +66
-1
lines changed
compiler/src/dotty/tools/dotc/transform/patmat Expand file tree Collapse file tree 4 files changed +66
-1
lines changed Original file line number Diff line number Diff line change @@ -708,6 +708,8 @@ object SpaceEngine {
708
708
else NoType
709
709
}.filter(_.exists)
710
710
parts
711
+ case tref : TypeRef if tref.symbol.isOpaqueAlias && ! tref.info.hiBound.isNothingType =>
712
+ rec(tref.info.hiBound, mixins)
711
713
case _ => ListOfNoType
712
714
end rec
713
715
@@ -853,7 +855,11 @@ object SpaceEngine {
853
855
}) ||
854
856
tpw.isRef(defn.BooleanClass ) ||
855
857
classSym.isAllOf(JavaEnum ) ||
856
- classSym.is(Case )
858
+ classSym.is(Case ) ||
859
+ (tpw.isInstanceOf [TypeRef ] && {
860
+ val tref = tpw.asInstanceOf [TypeRef ]
861
+ tref.symbol.isOpaqueAlias && ! tref.info.hiBound.isNothingType
862
+ })
857
863
858
864
! sel.tpe.hasAnnotation(defn.UncheckedAnnot )
859
865
&& ! sel.tpe.hasAnnotation(defn.RuntimeCheckedAnnot )
Original file line number Diff line number Diff line change
1
+ trait Foo
2
+ trait Bar
3
+
4
+ type FooOrBar = FooOrBar .Type
5
+ object FooOrBar :
6
+ opaque type Type <: (Foo | Bar ) = Foo | Bar
7
+
8
+ def bar : FooOrBar = new Bar {}
9
+
10
+ trait Buz
11
+
12
+ @ main def main =
13
+ val p : FooOrBar | Buz = FooOrBar .bar
14
+
15
+ p match
16
+ case _ : Foo => println(" foo" )
17
+ case _ : Buz => println(" buz" )
18
+ case _ : Bar => println(" bar" )
Original file line number Diff line number Diff line change
1
+ -- [E029] Pattern Match Exhaustivity Warning: tests/warn/i23620b.scala:20:2 --------------------------------------------
2
+ 20 | p match // warn
3
+ | ^
4
+ | match may not be exhaustive.
5
+ |
6
+ | It would fail on pattern case: _: Bar
7
+ |
8
+ | longer explanation available when compiling with `-explain`
9
+ -- [E029] Pattern Match Exhaustivity Warning: tests/warn/i23620b.scala:23:2 --------------------------------------------
10
+ 23 | p2 match { //warn
11
+ | ^^
12
+ | match may not be exhaustive.
13
+ |
14
+ | It would fail on pattern case: _: Bar
15
+ |
16
+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change
1
+ trait Foo
2
+ trait Bar
3
+
4
+ type FooOrBar = FooOrBar .Type
5
+ object FooOrBar :
6
+ opaque type Type <: (Foo | Bar ) = Foo | Bar
7
+
8
+ def bar : FooOrBar = new Bar {}
9
+
10
+ type OnlyFoo = OnlyFoo .Type
11
+ object OnlyFoo :
12
+ opaque type Type <: (Foo | Bar ) = Foo
13
+
14
+ def foo : OnlyFoo = new Foo {}
15
+
16
+ @ main def main =
17
+ val p : FooOrBar = FooOrBar .bar
18
+ val p2 : OnlyFoo = OnlyFoo .foo
19
+
20
+ p match // warn
21
+ case _ : Foo => println(" foo" )
22
+
23
+ p2 match { // warn
24
+ case _ : Foo => println(" foo" )
25
+ }
You can’t perform that action at this time.
0 commit comments