Skip to content

False-positive unreachable case warning with opaque types and List #19275

Closed
@Iltotore

Description

@Iltotore

Compiler version

3.3.1

Minimized code

unreachable.sc

//> using scala "3.3.1"
//> using file "unreachable_opaque.scala"

//Works for Seq and Set, does not work for List and Vector
val optionList: Option[Test[List[Int]]] = ???

optionList match
  case Some(value) => ??? // Compile warning: Unreachable case
  case None        => ???

unreachable_opaque.scala

//Works without <: A
opaque type Test[A] <: A = A

Output

[warn] .\unreachable.sc:8:8
[warn] Unreachable case
[warn]   case Some(value) => ??? // Compile warning: Unreachable case
[warn]        ^^^^^^^^^^^

Note that this only happen in very specific situations. Removing <: A from Test definition or replacing List by Seq or Set also removes the warning.

Expectation

No "unreachable case" warning since the case is actually reachable.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions