forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix provablyDisjoint handling enum constants with mixins (scala#21876)
Fixes scala#21860
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
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,16 @@ | ||
trait Figure | ||
sealed trait Corners { self: Figure => } | ||
|
||
enum Shape extends Figure: | ||
case Triangle extends Shape with Corners | ||
case Square extends Shape with Corners | ||
case Circle extends Shape | ||
case Ellipsis extends Shape | ||
|
||
def hasCorners(s: Shape): Boolean = s match | ||
case hasCorners: Corners => true // <--- reported as `Unreachable case` | ||
case _ => false | ||
|
||
class Test: | ||
def test(): Unit = | ||
println(hasCorners(Shape.Circle)) |
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,17 @@ | ||
trait Figure | ||
sealed trait Corners { self: Figure => } | ||
|
||
sealed abstract class Shape extends Figure | ||
object Shape: | ||
case object Triange extends Shape with Corners | ||
case object Square extends Shape with Corners | ||
case object Circle extends Shape | ||
case object Ellipsis extends Shape | ||
|
||
def hasCorners(s: Shape): Boolean = s match | ||
case hasCorners: Corners => true // <--- reported as `Unreachable case` | ||
case _ => false | ||
|
||
class Test: | ||
def test(): Unit = | ||
println(hasCorners(Shape.Circle)) |