scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

False negative unused import when there's a reference in macro-expanded code

Open kubukoz opened this issue 2 weeks ago • 1 comments

Compiler version

3.7.4, 3.8.1-RC1-bin-20251127-fd2172d-NIGHTLY

Minimized code

  1. main.scala
//> using scala 3.nightly
//> using option -Wunused:all
import ext.Reader
import ext.NonEmptyList

@main def run = locally {
  macros.demo
}
  1. ext.scala
package ext

case class Reader[F[_], A, B]()

case class NonEmptyList()
  1. macros.scala
import ext.Reader
import scala.quoted.*

object macros {
  inline def demo: Unit = ${ demoImpl }

  def demoImpl(
    using Quotes
  ): Expr[Unit] =
    '{
      val r: Reader[Option, String, String] = ???
      ()
    }

}

Output

[warn] ./demo.scala:4:12
[warn] unused import
[warn] import ext.NonEmptyList
[warn]            ^^^^^^^^^^^^^

Expectation

An additional warning on import ext.Reader.

kubukoz avatar Nov 27 '25 16:11 kubukoz