Skip to content

-Wunused:imports gives false positive when importing from a val #16930

Closed
@SethTisue

Description

@SethTisue
//> using scala "3.3.0-RC2"
//> using option "-Wunused:imports"

trait Outer:
  trait Used
  trait Unused

trait Test:
  val outer: Outer
  import outer.{Used, Unused}
  def foo(x: Any): Boolean =
    x.isInstanceOf[Used]

actual behavior (the first warning is a false positive):

[warn] ./S.scala:10:17: unused import
[warn]   import outer.{Used, Unused}
[warn]                 ^^^^
[warn] ./S.scala:10:23: unused import
[warn]   import outer.{Used, Unused}
[warn]                       ^^^^^^

expected behavior (I should only get the true positive):

[warn] ./S.scala:10:23: unused import
[warn]   import outer.{Used, Unused}
[warn]                       ^^^^^^

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