Skip to content

Commit 29dbb82

Browse files
committed
Only compute null warning for small problems
1 parent 48b6b56 commit 29dbb82

File tree

1 file changed

+3
-2
lines changed
  • compiler/src/dotty/tools/dotc/transform/patmat

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,12 +904,13 @@ class SpaceEngine(using Context) extends SpaceLogic {
904904
// If explicit nulls are enabled, this check isn't needed because most of the cases
905905
// that would trigger it would also trigger unreachability warnings.
906906
if (!ctx.explicitNulls && i == cases.length - 1 && !isNullLit(pat) ) {
907-
dedup(flatten(simplify(minus(covered, prevs)))).toList match {
907+
val spaces = flatten(simplify(minus(covered, prevs)))
908+
if spaces.lengthCompare(10) < 0 then
909+
dedup(spaces).toList match
908910
case Typ(`constantNullType`, _) :: Nil =>
909911
report.warning(MatchCaseOnlyNullWarning(), pat.srcPos)
910912
case s =>
911913
debug.println("`_` matches = " + s)
912-
}
913914
}
914915
}
915916
}

0 commit comments

Comments
 (0)