Skip to content

Spurious "Unreachable case" warning #14102

@odersky

Description

@odersky

Compiler version

3.1.1-RC1

Minimized example

trait T[-X]
case class CC[-X](x: List[T[X]]) extends T[Nothing]
case class Id[-X](x: String) extends T[X]

def f[X](tree: T[X]) = tree match
  case CC(Id("hi") :: Nil) => ???
  case CC(refs) => ???
  case _ => ???

Output

-- [E030] Match case Unreachable Warning: ../../new/test.scala:8:7 -------------
8 |  case CC(refs) => ???
  |       ^^^^^^^^
  |       Unreachable case
1 warning found

Expectation

No warning

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions