Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Iltotore opened this issue Dec 15, 2023 · 0 comments · Fixed by #19368
Closed

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

Iltotore opened this issue Dec 15, 2023 · 0 comments · Fixed by #19368

Comments

@Iltotore
Copy link
Contributor

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.

@Iltotore Iltotore added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 15, 2023
@sjrd sjrd added area:pattern-matching and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Dec 15, 2023
@Kordyjan Kordyjan added this to the 3.4.1 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants