Skip to content

False positive warning: Unused import of a package #23047

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

Open
OndrejSpanel opened this issue Apr 25, 2025 · 2 comments
Open

False positive warning: Unused import of a package #23047

OndrejSpanel opened this issue Apr 25, 2025 · 2 comments
Assignees
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug regression This worked in a previous version but doesn't anymore

Comments

@OndrejSpanel
Copy link
Member

OndrejSpanel commented Apr 25, 2025

Compiler version

3.7.0-RC1, 3.7.0-RC4

Minimized code

Main.scala:

package some.example
package demo

import some.example

object Main {

  def generic[T](x: Any): T = null.asInstanceOf[T]

  def main(args: Array[String]): Unit = {
    generic[example.Util](0)
  }
}

Util.scala:

package some.example

class Util

Output

unused import
import some.example

Expectation

The code does not compile without the import.

Note

The code does not make much sense, it can be fixed by using generic[Util](0) instead of generic[example.Util](0), but still, it probably should not create a false warning.

@OndrejSpanel OndrejSpanel added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 25, 2025
@Gedochao Gedochao added regression This worked in a previous version but doesn't anymore stat:needs bisection Need to use nightly builds and git bisect to find out the commit where this issue was introduced area:linting Linting warnings enabled with -W or -Xlint and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 25, 2025
@Gedochao
Copy link
Contributor

Last good release: 3.7.0-RC1-bin-20250127-89c20f8-NIGHTLY
First bad release: 3.7.0-RC1-bin-20250128-9cb97ec-NIGHTLY
c65d45d is the first bad commit (#20894)
cc @som-snytt

@Gedochao Gedochao removed the stat:needs bisection Need to use nightly builds and git bisect to find out the commit where this issue was introduced label Apr 25, 2025
@som-snytt som-snytt self-assigned this Apr 25, 2025
@som-snytt
Copy link
Contributor

som-snytt commented Apr 25, 2025

This will be a follow-up to recent #22987 where types "in some positions" are not processed.

Not to neglect to say, Thanks for the report, @OndrejSpanel !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug regression This worked in a previous version but doesn't anymore
Projects
None yet
Development

No branches or pull requests

3 participants