Skip to content

Unreachable case involving path dependent types #12681

Closed
@bishabosha

Description

@bishabosha

Compiler version

3.0.0

Minimized code

object Examples {

  case class Leaf1() extends i.Root
  case class Leaf2() extends i.Branch

  val i = new Inner()

  class Inner {

    sealed trait Root
    sealed trait Branch extends Root

    // simulate ordinal method of a Mirror.SumOf generated at this call site
    def myOrdinal(r: Root): Int = r match {
      case _: Examples.Leaf1 => 0
      case _: Inner.this.Branch => 1
    }
  }

}

Output

-- [E030] Match case Unreachable Warning: example3.scala:16:11 -----------------
16 |      case _: Inner.this.Branch => 1
   |           ^^^^^^^^^^^^^^^^^^^^
   |           Unreachable case
1 warning found

Expectation

in Scala 2.13.6 we get the type error

cmd0.sc:14: pattern type is incompatible with expected type;
 found   : ammonite.$sess.cmd0.Examples.Leaf1
 required: Inner.this.Root
      case _: Examples.Leaf1 => 0
                       ^
Compilation Failed

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions