File tree Expand file tree Collapse file tree 6 files changed +41
-4
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 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 {
4646 case rt => tree.tpe
4747 val translated = new Translator (matchType, this ).translateMatch(tree)
4848
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)
5351
5452 translated.ensureConforms(matchType)
5553 }
Original file line number Diff line number Diff line change @@ -917,6 +917,7 @@ object SpaceEngine {
917917 ! sel.tpe.hasAnnotation(defn.UncheckedAnnot )
918918 && ! sel.tpe.widen.isRef(defn.QuotedExprClass )
919919 && ! sel.tpe.widen.isRef(defn.QuotedTypeClass )
920+ && tpd.enclosingInlineds.isEmpty // Skip reachability on inlined code (eg i19157/i22212)
920921
921922 def checkReachability (m : Match )(using Context ): Unit = trace(i " checkReachability( $m) " ):
922923 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