Skip to content

Falsely declaring import as unused #25100

@felix-hedenstrom

Description

@felix-hedenstrom

Compiler version

This occurs in 3.8.0 and 3.8.1, but not in 3.7.4

Minimized code

//> using scala 3.8.0
//> using option -language:strictEquality
//> using option -Wunused:all

case class Foo(value: String)
case object Bar

object Import {
  given CanEqual[Foo | Bar.type, Foo | Bar.type] = CanEqual.derived
}

@main
def main(): Unit = {
  import Import.given
  val i: Foo | Bar.type = Foo("Foo")

  i match {
    case i: Foo => println("i is a Foo")
    case Bar => println("i is a Long")
  }
}

Output

[warn] ./unused.scala:14:17
[warn] unused import
[warn]   import Import.given
[warn]                 ^^^^^
i is a Foo

Expectation

No warning. Omitting the import Import.given causes a compile error, so it is not unused. This worked as expected in 3.7.4

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