-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15553 from dwijnand/space/sealed-abstracts-redund…
…ancy space: Fix how sealed abstract classes decompose
- Loading branch information
Showing
2 changed files
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// scalac: -Werror | ||
sealed trait Coverage | ||
sealed abstract case class Range(min: Double, max: Double) extends Coverage | ||
case object Empty extends Coverage | ||
|
||
object Test: | ||
def mkCoverage(min: Double, max: Double): Coverage = | ||
if min < max then new Range(min, max) {} else Empty | ||
|
||
def meth(c1: Coverage, c2: Coverage): Coverage = (c1, c2) match | ||
case (Empty, _) => Empty | ||
case (_, Empty) => Empty // was: Unreachable case | ||
case (Range(a1, b1), Range(a2, b2)) => mkCoverage(a1 max a2, b1 min b2) |