Skip to content

False positive warning: unused import when var symbol is used only as assignment target #22970

Closed
@OndrejSpanel

Description

@OndrejSpanel

Compiler version

3.7.0-RC1
3.7.0-RC2

Minimized code

Compile with -Wunused:imports:

object X {
  var global = 0
}

object Main {
  import X.global
  def main(args: Array[String]): Unit = {
    global = 1
  }
}

Output

unused import
  import X.global

Expectation

The warning should not be there. The code requires the import to compile.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions