Skip to content

Missing unreachable case warnings #4661

Closed
@smarter

Description

@smarter

Given:

trait Foo
class One extends Foo
class Two extends Foo
class Three extends Foo

object Test {
  def test(f: Foo) = f match {
    case f: Foo =>
    case f: One =>
    case f: Two =>
    case f: Three =>
  }
}

We should get three warnings since the three last cases are not reachable, but we only get one for the last case:

-- [E120] Only null matched Warning: try/caseun.scala:11:9 ---------------------
11 |    case f: Three =>
   |         ^^^^^^^^
   |         Only null is matched. Consider using `case null =>` instead.

(The warning itself is a bit confusing but that's a separate issue: #4660)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions