Skip to content

False positive unused import on type used in macro type pattern #22981

Closed
@mrdziuban

Description

@mrdziuban

Compiler version

3.5.2, 3.6.4 and latest nightly 3.7.1-RC1-bin-20250411-98c84c3-NIGHTLY

Minimized code

import scala.quoted.*

object test {
  import scala.concurrent.duration.FiniteDuration
  
  def applyImpl[A: Type](using Quotes): Expr[Unit] =
    Type.of[A] match { case '[type d <: FiniteDuration; d] => '{ () } }
}

Output

-- [E198] Unused Symbol Warning: -----------------------------------------------
4 |  import scala.concurrent.duration.FiniteDuration
  |                                   ^^^^^^^^^^^^^^
  |                                   unused import

Expectation

The import should not be reported unused since it's used in applyImpl.

Note that the import is only reported unused when using a bounded type like '[type d <: FiniteDuration; d] -- it's not reported unused if I just do '[FiniteDuration].

Metadata

Metadata

Assignees

Labels

area:lintingLinting warnings enabled with -W or -Xlintitype:bugregressionThis worked in a previous version but doesn't anymore

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions