Skip to content

Backport "Fix provablyDisjoint handling enum constants with mixins" to 3.3 LTS #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,7 @@ object TypeComparer {

def explaining[T](op: ExplainingTypeComparer => T, short: Boolean = false)(using Context): T =
comparing(_.explaining(op, short))

def tracked[T](op: TrackingTypeComparer => T)(using Context): T =
comparing(_.tracked(op))
}
Expand Down
16 changes: 16 additions & 0 deletions tests/warn/i21860.scala
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))
17 changes: 17 additions & 0 deletions tests/warn/i21860.unenum.scala
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))