Closed
Description
I tried adding the new unused flag (from #16157) to my work codebase and was surprised that it warned about unused import when used with the json library circe
s derivation of json Encoders from case classes. ( case class Foo(i: Int) derives Encoder.AsObject
). A minimal reproducer independent of circe is below. I see no error when trying to derive the "top level" typeclass and not a subtype.
Compiler version
With nightly: 3.3.0-RC1-bin-20230112-be10bc6-NIGHTLY
Minimized code
//> using scala "3.3.0-RC1-bin-20230112-be10bc6-NIGHTLY"
//> using option "-Wunused:all"
object myPackage:
trait CaseClassName[A]:
def name: String
object CaseClassName:
trait CaseClassByStringName[A] extends CaseClassName[A]
import scala.deriving.Mirror
object CaseClassByStringName:
inline final def derived[A](using inline A: Mirror.Of[A]): CaseClassByStringName[A] =
new CaseClassByStringName[A]:
def name: String = A.toString
import myPackage.CaseClassName
case class CoolClass(i: Int) derives CaseClassName.CaseClassByStringName
println(summon[CaseClassName[CoolClass]].name)
Output
[warn] ./unused-typeclass-derivation.sc:16:18: unused import
[warn] import myPackage.CaseClassName
[warn] ^^^^^^^^^^^^^
Expectation
The import is needed and used 2 places (at the summon and at the derives), so no warn should be provided.