Skip to content

False positive unused import on type used in macro type pattern #22981

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
mrdziuban opened this issue Apr 11, 2025 · 1 comment · May be fixed by #22987
Open

False positive unused import on type used in macro type pattern #22981

mrdziuban opened this issue Apr 11, 2025 · 1 comment · May be fixed by #22987
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

@mrdziuban
Copy link

Compiler version

3.5.2, 3.6.4 and latest nightly 3.7.1-RC1-bin-20250411-98c84c3-NIGHTLY

Minimized code

import scala.quoted.*

object test {
  import scala.concurrent.duration.FiniteDuration
  
  def applyImpl[A: Type](using Quotes): Expr[Unit] =
    Type.of[A] match { case '[type d <: FiniteDuration; d] => '{ () } }
}

Output

-- [E198] Unused Symbol Warning: -----------------------------------------------
4 |  import scala.concurrent.duration.FiniteDuration
  |                                   ^^^^^^^^^^^^^^
  |                                   unused import

Expectation

The import should not be reported unused since it's used in applyImpl.

Note that the import is only reported unused when using a bounded type like '[type d <: FiniteDuration; d] -- it's not reported unused if I just do '[FiniteDuration].

@mrdziuban mrdziuban added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 11, 2025
@som-snytt som-snytt linked a pull request Apr 12, 2025 that will close this issue
@som-snytt som-snytt self-assigned this Apr 12, 2025
@som-snytt som-snytt 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 Apr 12, 2025
@Gedochao Gedochao added the regression This worked in a previous version but doesn't anymore label Apr 14, 2025
@Gedochao
Copy link
Contributor

Last good release: 3.5.0-RC1-bin-20240502-05354ba-NIGHTLY
First bad release: 3.5.0-RC1-bin-20240506-1cdf99f-NIGHTLY
The bisect script struggles in between these versions, the culprit is likely somewhere between d4de2cb..1cdf99f.

I can see a solution is already in progress, let me know if we need to bisect this further.

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

Successfully merging a pull request may close this issue.

3 participants