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 unused import warning for scala.compiletime.deferred #22376

Open
OlgaDor opened this issue Jan 15, 2025 · 1 comment · May be fixed by #20894
Open

false unused import warning for scala.compiletime.deferred #22376

OlgaDor opened this issue Jan 15, 2025 · 1 comment · May be fixed by #20894
Labels
area:linting Linting warnings enabled with -W or -Xlint itype:bug

Comments

@OlgaDor
Copy link

OlgaDor commented Jan 15, 2025

Compiler version

Scala 3.6.2 with scalacOptions "-Wunused:imports"

Minimized code

import scala.compiletime.deferred

class Context

trait Foo:
  given context: Context = deferred

Output

Scala compiler returns a warning
unused import import scala.compiletime.deferred

The incorrect warning results in misleading highlighting in IntelliJ IDEA when compiler-based highlighting is enabled

Expectation

The compiler should not return an "unused import" warning for scala.compiletime.deferred, as it is clearly used in the code

@OlgaDor OlgaDor added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 15, 2025
@som-snytt
Copy link
Contributor

som-snytt commented Jan 15, 2025

See #21805 which is an umbrella ticket for compiletime.

I'll work my way through the use cases, but I just pushed this one, thanks. In this case, I think it will not support name fidelity, e.g.,

import compiletime.deferred as dufuhhed

Edit: actually the warning would take the highest precedence import in any case.

But TIL:

   |Note that `deferred` can only be used under its own name when implementing a given in a trait; `defuhhed` is not accepted.

@Gedochao Gedochao added 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 Jan 16, 2025
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants