Skip to content

False positive unused import on 3.8 for discarded import #24633

@mrdziuban

Description

@mrdziuban

Compiler version

3.8.0-RC1, 3.8.0-RC1, and latest nightly 3.8.1-RC1-bin-20251202-9eb843d-NIGHTLY

Minimized code

//> using scala 3.8.1-RC1-bin-20251202-9eb843d-NIGHTLY
//> using options -Wunused:imports

object foo {
  val min = 0
  val max = 1
}

def test(max: Int) = {
  import foo.{max as _, *}
  s"$min - $max"
}

Output

-- [E198] Unused Symbol Warning: -----------------------------------------------
7 |  import foo.{max as _, *}
  |              ^^^^^^^^
  |              unused import

Expectation

The import should not be reported as unused. If I change it to import foo.*, then I get this error:

-- [E049] Reference Error: -----------------------------------------------------
8 |  s"$min - $max"
  |            ^^^
  |            Reference to max is ambiguous.
  |            It is both defined in method test
  |            and imported subsequently by import foo._

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

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions