Skip to content

Commit 4f22672

Browse files
committed
Re-fix skipping match analysis & inlining
1 parent b981231 commit 4f22672

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
@@ -902,9 +902,6 @@ object SpaceEngine {
902902
}
903903

904904
def checkMatch(m: Match)(using Context): Unit =
905-
checkMatchExhaustivityOnly(m)
906-
if reachabilityCheckable(m.selector) then checkReachability(m)
907-
908-
def checkMatchExhaustivityOnly(m: Match)(using Context): Unit =
909905
if exhaustivityCheckable(m.selector) then checkExhaustivity(m)
906+
if reachabilityCheckable(m.selector) then checkReachability(m)
910907
}

0 commit comments

Comments
 (0)