Skip to content

Commit 208a728

Browse files
dwijnandWojciechMazur
authored andcommitted
Move checkMatch into SpaceEngine
... makes it easier to disable one of them. [Cherry-picked dbb97ca]
1 parent 1b7356e commit 208a728

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

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

Lines changed: 1 addition & 2 deletions
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
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ object SpaceEngine {
882882
case _ => tp
883883
})
884884

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

@@ -905,7 +905,7 @@ object SpaceEngine {
905905
report.warning(PatternMatchExhaustivity(showSpaces(deduped), m), m.selector)
906906
}
907907

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

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

921921
val selTyp = toUnderlying(m.selector.tpe).dealias
@@ -967,4 +967,8 @@ object SpaceEngine {
967967
i += 1
968968
}
969969
}
970+
971+
def checkMatch(m: Match)(using Context): Unit =
972+
if exhaustivityCheckable(m.selector) then checkExhaustivity(m)
973+
if reachabilityCheckable(m.selector) then checkReachability(m)
970974
}

scaladoc-js/common/src/utils/html.scala

Lines changed: 2 additions & 2 deletions
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)