Skip to content

Spurious "Only null is matched" warning due to nesting? #12408

@dwijnand

Description

@dwijnand

Compiler version

3.0.0-RC3

Minimized code

class X[T] {
  sealed trait P

  private case class A(id: Long)          extends P
  private case class B(id: Long, x: Long) extends P
  private case class C(id: Long)          extends P

  def m(p: P): Unit = p match {
    case B(_, x) =>
    case _       =>
  }
}

Output

$ scalac3 Hub.scala
-- [E121] Pattern Match Warning: Hub.scala:10:9 --------------------------------
10 |    case _       =>
   |         ^
   |         Only null is matched. Consider using case null => instead.
1 warning found

Expectation

No warning.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions