Skip to content

2.13 regression: false negative, missing unreachable warning after extractor returning Some #13085

Open
@SethTisue

Description

@SethTisue

both Scala 2.12.20 and Scala 3.6.3 give an unreachable warning but Scala 2.13 does not:

trait Tree
object Tree {
  def unapply(tree: Tree): Some[Int] = ???
}
object Test {
  def foo(tree: Tree) =
    tree match {
      case Tree(_) => ???
      case _ => "unreachable"
    }
}

note that adding a case null => ??? line does causes the unreachable warning to emerge

the Scala 3 warning text is helpfully explicit about the status of null:

-- [E121] Pattern Match Warning: -----------------------------------------------
9 |      case _ => "unreachable"
  |           ^
  |Unreachable case except for null (if this is intentional, consider writing case null => instead).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions