Skip to content

False unreachable warning #1917

Closed
Closed
@odersky

Description

@odersky

Given:

object Test {
  sealed trait SearchResult
  case class Success() extends SearchResult
  val Fail = new SearchResult {}
  val x: SearchResult = ???

  x match {
    case x: Success => x
    case x => x
  }
}

we get:

-- [E030] Match case Unreachable Warning: unreachable.scala --------------------
9 |        case x => x
  |               ^^^^
  |               unreachable code

one warning found

The warning should not be issued, since the line is reachable.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions