Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

false-positive "unused import" warning #21525

Open
xuwei-k opened this issue Aug 31, 2024 · 0 comments
Open

false-positive "unused import" warning #21525

xuwei-k opened this issue Aug 31, 2024 · 0 comments
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:bug Spree Suitable for a future Spree

Comments

@xuwei-k
Copy link
Contributor

xuwei-k commented Aug 31, 2024

Compiler version

  • 3.6.0-RC1-bin-20240828-5e83606-NIGHTLY
  • 3.5.1-RC2
  • 3.5.0
  • 3.4.3
  • 3.3.3

Minimized example

build.sbt

scalaVersion := "3.5.1-RC2"

scalacOptions += "-Wunused:imports"

A.scala

import scala.reflect.TypeTest

trait A {
  type B
  type C <: B

  given instance: TypeTest[B, C]
}

def f(a: A, b: a.B): Boolean = {
  import a.C
  b match {
    case _: C =>
      true
    case _ =>
      false
  }
}

Output Error/Warning message

[warn] -- [E198] Unused Symbol Warning: false-unused-import-warn-example-project/A.scala:11:11 
[warn] 11 |  import a.C
[warn]    |           ^
[warn]    |           unused import

Why this Error/Warning was not helpful

a.C is not unused

Suggested improvement

don't warn

@xuwei-k xuwei-k added area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:enhancement stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 31, 2024
@Gedochao Gedochao added itype:bug Spree Suitable for a future Spree and removed stat:needs triage Every issue needs to have an "area" and "itype" label itype:enhancement labels Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc better-errors Issues concerned with improving confusing/unhelpful diagnostic messages itype:bug Spree Suitable for a future Spree
Projects
None yet
Development

No branches or pull requests

2 participants