Skip to content

Commit 8bc0df6

Browse files
committed
Re-fix skipping match analysis & inlining
1 parent 4828244 commit 8bc0df6

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ class PatternMatcher extends MiniPhase {
3535

3636
override def runsAfter: Set[String] = Set(ElimRepeated.name)
3737

38-
private val InInlinedCode = new util.Property.Key[Boolean]
39-
private def inInlinedCode(using Context) = ctx.property(InInlinedCode).getOrElse(false)
40-
41-
override def prepareForInlined(tree: Inlined)(using Context): Context =
42-
if inInlinedCode then ctx
43-
else ctx.fresh.setProperty(InInlinedCode, true)
44-
4538
override def transformMatch(tree: Match)(using Context): Tree =
4639
if (tree.isInstanceOf[InlineMatch]) tree
4740
else {
@@ -53,13 +46,10 @@ class PatternMatcher extends MiniPhase {
5346
case rt => tree.tpe
5447
val translated = new Translator(matchType, this).translateMatch(tree)
5548

56-
if !inInlinedCode then
49+
// Skip analysis on inlined code (eg pos/i19157)
50+
if !tpd.enclosingInlineds.nonEmpty then
5751
// check exhaustivity and unreachability
5852
SpaceEngine.checkMatch(tree)
59-
else
60-
// only check exhaustivity, as inlining may generate unreachable code
61-
// like in i19157.scala
62-
SpaceEngine.checkMatchExhaustivityOnly(tree)
6353

6454
translated.ensureConforms(matchType)
6555
}

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,6 @@ object SpaceEngine {
901901
}
902902

903903
def checkMatch(m: Match)(using Context): Unit =
904-
checkMatchExhaustivityOnly(m)
905-
if reachabilityCheckable(m.selector) then checkReachability(m)
906-
907-
def checkMatchExhaustivityOnly(m: Match)(using Context): Unit =
908904
if exhaustivityCheckable(m.selector) then checkExhaustivity(m)
905+
if reachabilityCheckable(m.selector) then checkReachability(m)
909906
}

0 commit comments

Comments
 (0)