Skip to content

False-positive unreachable warning for a match using local object #21218

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

Closed
WojciechMazur opened this issue Jul 18, 2024 · 0 comments · Fixed by #21532
Closed

False-positive unreachable warning for a match using local object #21218

WojciechMazur opened this issue Jul 18, 2024 · 0 comments · Fixed by #21532
Assignees
Labels
area:pattern-matching itype:bug regression This worked in a previous version but doesn't anymore

Comments

@WojciechMazur
Copy link
Contributor

Based on false-positive warning found in apache/pekko#1398

Compiler version

Last good release: 3.4.0-RC1-bin-20230901-89e8dba-NIGHTLY
First bad release: 3.4.0-RC1-bin-20230904-6dc3737-NIGHTLY
The first bad commit could be any of:
cae6786
4421d12

Affects 3.3.4-RC1 - the PR introducing regression was backported before detecting regression

Minimized code

def Test[U, A](thisElem: A, thatElem: U) = {
  case object passedEnd
  val any: Seq[Any] = ???
  any.zip(any)
    .map {
      case (`passedEnd`, r: U @unchecked) => (thisElem, r)
      case (l: A @unchecked, `passedEnd`) => (l, thatElem)
      case t: (A, U) @unchecked           => t // false-positive warning
    }
}

Output

-- [E030] Match case Unreachable Warning: /Users/wmazur/projects/sandbox/src/main/scala/test.scala:68:11 
68 |      case t: (A, U) @unchecked           => t
   |           ^^^^^^^^^^^^^^^^^^^^
   |           Unreachable case

Expectation

It should not warn for the 3rd case in the map function. This case is easily reachable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:pattern-matching itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants