File tree 6 files changed +41
-4
lines changed
compiler/src/dotty/tools/dotc/transform
6 files changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -46,10 +46,8 @@ class PatternMatcher extends MiniPhase {
46
46
case rt => tree.tpe
47
47
val translated = new Translator (matchType, this ).translateMatch(tree)
48
48
49
- // Skip analysis on inlined code (eg pos/i19157)
50
- if ! tpd.enclosingInlineds.nonEmpty then
51
- // check exhaustivity and unreachability
52
- SpaceEngine .checkMatch(tree)
49
+ // check exhaustivity and unreachability
50
+ SpaceEngine .checkMatch(tree)
53
51
54
52
translated.ensureConforms(matchType)
55
53
}
Original file line number Diff line number Diff line change @@ -917,6 +917,7 @@ object SpaceEngine {
917
917
! sel.tpe.hasAnnotation(defn.UncheckedAnnot )
918
918
&& ! sel.tpe.widen.isRef(defn.QuotedExprClass )
919
919
&& ! sel.tpe.widen.isRef(defn.QuotedTypeClass )
920
+ && tpd.enclosingInlineds.isEmpty // Skip reachability on inlined code (eg i19157/i22212)
920
921
921
922
def checkReachability (m : Match )(using Context ): Unit = trace(i " checkReachability( $m) " ):
922
923
val selTyp = toUnderlying(m.selector.tpe).dealias
Original file line number Diff line number Diff line change
1
+
2
+ -- [E029] Pattern Match Exhaustivity Warning: tests/warn/i22212/Test_2.scala:3:19 --------------------------------------
3
+ 3 | Macro.makeMatch() // warn: match may not be exhaustive.
4
+ | ^^^^^^^^^^^^^^^^^
5
+ | match may not be exhaustive.
6
+ |
7
+ | It would fail on pattern case: Baz
8
+ |---------------------------------------------------------------------------------------------------------------------
9
+ |Inline stack trace
10
+ |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
11
+ |This location contains code that was inlined from Macro_1.scala:7
12
+ 7 | (_: Foo) match
13
+ | ^^^^^^
14
+ |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15
+ |This location contains code that was inlined from Macro_1.scala:7
16
+ 7 | (_: Foo) match
17
+ | ^
18
+ 8 | case Bar => ()
19
+ ---------------------------------------------------------------------------------------------------------------------
20
+ |
21
+ | longer explanation available when compiling with `-explain`
Original file line number Diff line number Diff line change
1
+ sealed trait Foo
2
+ case object Bar extends Foo
3
+ case object Baz extends Foo
Original file line number Diff line number Diff line change
1
+ import scala .quoted ._
2
+
3
+ object Macro {
4
+ inline def makeMatch () = $ {makeMatchImpl}
5
+ def makeMatchImpl (using Quotes ) = {
6
+ ' {
7
+ (_ : Foo ) match
8
+ case Bar => ()
9
+ }
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ object Test :
2
+ def main (args : Array [String ]): Unit =
3
+ Macro .makeMatch() // warn: match may not be exhaustive.
You can’t perform that action at this time.
0 commit comments