scala/scala3

False positive unused parameter warning in 3.7 nightly on method with default parameters

Closed this issue · 2 comments

Compiler version

3.7.0-RC1-bin-20250306-73ba485-NIGHTLY

Minimized code

def test[I, A](in: I)(
  run: I => Either[Throwable, A],
  onErr: Throwable => Throwable = identity[Throwable]
): Either[Throwable, A] =
  run(in) match {
    case Left(t) => Left(onErr(t))
    case r @ Right(_) => r
  }

Output

-- [E198] Unused Symbol Warning: /Users/matt/scala3.7-nightly-unused/src/main/scala/example/Test.scala:1:15 ------------
1 |def test[I, A](in: I)(
  |               ^^
  |               unused explicit parameter

Expectation

in should not be reported unused since it's passed to run. If I remove the default param for onErr then it compiles without warning

Possibly related to (or a duplicate of) #22746

Example is included in test for the other ticket.