Skip to content

False positive unused private object in 3.7 nightly when givens in object are used #22744

Closed
@mrdziuban

Description

@mrdziuban

Compiler version

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

Minimized code

With -Wunused:privates enabled:

object test {
  private trait Foo[A] { val value: A }

  private object Foo {
    given int: Foo[Int] = new Foo[Int] { val value = 1 }
  }

  val i = summon[Foo[Int]].value
}

Output

-- [E198] Unused Symbol Warning: /Users/matt/scala3.7-nightly-unused/src/main/scala/example/Test.scala:4:2 -------------
4 |  private object Foo {
  |  ^
  |  unused private member

Expectation

object Foo should not be reported unused since given int from it is summoned and used

Metadata

Metadata

Assignees

Labels

area:lintingLinting warnings enabled with -W or -Xlintitype:bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions