Skip to content

Override check does not account for match type. #7894

Closed
@esse-byte

Description

@esse-byte

minimized code

scala> case class Box[T](t: T)
// defined case class Box

scala> type Boxed[T <: Tuple] <: Tuple = T match {
     |   case Unit => Unit
     |   case h *: t => Box[h] *: Boxed[t]
     | }

scala> trait Cmp[T <: Tuple] { def cmp(t: T, b: Boxed[T]): Boolean }
// defined trait Cmp

scala> object UnitCmp extends Cmp[Unit] {
     |   def cmp(t: Unit, b: Unit): Boolean = true
     | }
2 |  def cmp(t: Unit, b: Unit): Boolean = true
  |      ^
  |error overriding method cmp in trait Cmp of type (t: Unit, b: Boxed[Unit]): Boolean;
  |  method cmp of type (t: Unit, b: Unit): Boolean has incompatible type
1 |object UnitCmp extends Cmp[Unit] {
  |       ^
  |object creation impossible, since def cmp(t: Unit, b: Boxed[Unit]): Boolean is not defined
  |(The class implements a member with a different type: def cmp(t: Unit, b: Unit): Boolean)

scala> object UnitCmp extends Cmp[Unit] {
     |   def cmp(t: Unit, b: Boxed[Unit]): Boolean = true
     | }
2 |  def cmp(t: Unit, b: Boxed[Unit]): Boolean = true
  |      ^
  |error overriding method cmp in trait Cmp of type (t: Unit, b: Boxed[Unit]): Boolean;
  |  method cmp of type (t: Unit, b: Unit): Boolean has incompatible type
1 |object UnitCmp extends Cmp[Unit] {
  |       ^
  |object creation impossible, since def cmp(t: Unit, b: Boxed[Unit]): Boolean is not defined
  |(The class implements a member with a different type: def cmp(t: Unit, b: Unit): Boolean)

expectation

I'm not sure if it is just the limitation of Match Type or a bug.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions