Skip to content

Commit dbb97ca

Browse files
committed
Move checkMatch into SpaceEngine
... makes it easier to disable one of them.
1 parent 97e4401 commit dbb97ca

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

Diff for: compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ class PatternMatcher extends MiniPhase {
5555

5656
if !inInlinedCode then
5757
// check exhaustivity and unreachability
58-
SpaceEngine.checkExhaustivity(tree)
59-
SpaceEngine.checkRedundancy(tree)
58+
SpaceEngine.checkMatch(tree)
6059

6160
translated.ensureConforms(matchType)
6261
}

Diff for: compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

+7-3
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ object SpaceEngine {
880880
case _ => tp
881881
})
882882

883-
def checkExhaustivity(m: Match)(using Context): Unit = if exhaustivityCheckable(m.selector) then trace(i"checkExhaustivity($m)", debug) {
883+
def checkExhaustivity(m: Match)(using Context): Unit = trace(i"checkExhaustivity($m)", debug) {
884884
val selTyp = toUnderlying(m.selector.tpe).dealias
885885
debug.println(i"selTyp = $selTyp")
886886

@@ -903,7 +903,7 @@ object SpaceEngine {
903903
report.warning(PatternMatchExhaustivity(showSpaces(deduped), m), m.selector)
904904
}
905905

906-
private def redundancyCheckable(sel: Tree)(using Context): Boolean =
906+
private def reachabilityCheckable(sel: Tree)(using Context): Boolean =
907907
// Ignore Expr[T] and Type[T] for unreachability as a special case.
908908
// Quote patterns produce repeated calls to the same unapply method, but with different implicit parameters.
909909
// Since we assume that repeated calls to the same unapply method overlap
@@ -913,7 +913,7 @@ object SpaceEngine {
913913
&& !sel.tpe.widen.isRef(defn.QuotedExprClass)
914914
&& !sel.tpe.widen.isRef(defn.QuotedTypeClass)
915915

916-
def checkRedundancy(m: Match)(using Context): Unit = if redundancyCheckable(m.selector) then trace(i"checkRedundancy($m)", debug) {
916+
def checkReachability(m: Match)(using Context): Unit = trace(i"checkReachability($m)", debug) {
917917
val cases = m.cases.toIndexedSeq
918918

919919
val selTyp = toUnderlying(m.selector.tpe).dealias
@@ -965,4 +965,8 @@ object SpaceEngine {
965965
i += 1
966966
}
967967
}
968+
969+
def checkMatch(m: Match)(using Context): Unit =
970+
if exhaustivityCheckable(m.selector) then checkExhaustivity(m)
971+
if reachabilityCheckable(m.selector) then checkReachability(m)
968972
}

Diff for: scaladoc-js/common/src/utils/html.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object HTML {
2626
case ("id", id) => elem.id = id
2727
case ("class", value) => value.split("\\s+").foreach(cls => elem.classList.add(cls))
2828
case (attr, value) => elem.setAttribute(attr, value)
29-
case s: Seq[AppliedAttr] => unpackAttributes(s*)
29+
case s: Seq[AppliedAttr @unchecked] => unpackAttributes(s*)
3030
}
3131

3232
unpackTags(tags*)
@@ -118,4 +118,4 @@ object HTML {
118118
val titleAttr =Attr("title")
119119
val onkeyup = Attr("onkeyup")
120120

121-
}
121+
}

0 commit comments

Comments
 (0)