Skip to content

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

Closed
@WojciechMazur

Description

@WojciechMazur

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions