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

Regression in arainko/ducktape: -Wunused:all false-positive in quotes #18409

Closed
WojciechMazur opened this issue Aug 16, 2023 · 3 comments · Fixed by #18412
Closed

Regression in arainko/ducktape: -Wunused:all false-positive in quotes #18409

WojciechMazur opened this issue Aug 16, 2023 · 3 comments · Fixed by #18412
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

@WojciechMazur
Copy link
Contributor

Compiler version

3.3.1-RC5
3.4.0-RC1-bin-20230815-ca6a80e-NIGHTLY
Works in 3.3.0 -version` instead).

Bisect points to b7a7227

Minimized code

//> using options -Wunused:all
import scala.quoted.*

object model {
  trait Transformer[Source, Dest] {
    def transform(from: Source): Dest
  }
  object Transformer {
    trait ForProduct[A, B] extends Transformer[A, B]
  }
}

object Ops {
  import model.Transformer // unused import false-positive

  def unapply(using Quotes)(term: quotes.reflect.Term): Option[String] = {
    term.asExpr match {
      case '{
            ($transformer: Transformer.ForProduct[a, b]).transform($appliedTo)
          } =>
        Some("")
      case other => None
    }
  }
}

Output

[warn] ./bisect/main.scala:14:16
[warn] unused import
[warn]   import model.Transformer // unused import false-positive
[warn]             

Expectation

Should not mark this import as unused

@WojciechMazur WojciechMazur added itype:bug regression This worked in a previous version but doesn't anymore area:linting Linting warnings enabled with -W or -Xlint labels Aug 16, 2023
@WojciechMazur
Copy link
Contributor Author

@szymon-rd I think you've worked recently on some regression related to -Wunused, is it possibly the same issue?

@szymon-rd
Copy link
Contributor

Hard to say right now - it's a bit of a different story with quotes. I will look into it.

@szymon-rd szymon-rd self-assigned this Aug 16, 2023
@nicolasstucki
Copy link
Contributor

The cause of this comes from an optimization in how we type quote splices in https://github.com/lampepfl/dotty/blob/main/compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala#L263-L266. @szymon-rd I should take this over. Removing that case fixes the issue, but I need to see if there are other consequences.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 16, 2023
These trees where removed as part of an optimization. However, they
should be kept around to allow for better error messages and IDE navigation.

The type of the ascription in pickled in the TASTy file but is elided in
the pickled quote pattern (same optimization already done later).

Fixes scala#18409
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 16, 2023
These trees where removed as part of an optimization. However, they
should be kept around to allow for better error messages and IDE navigation.

The type of the ascription in pickled in the TASTy file but is elided in
the pickled quote pattern (same optimization already done later).

Fixes scala#18409
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 16, 2023
These trees where removed as part of an optimization. However, they
should be kept around to allow for better error messages and IDE navigation.

The type of the ascription in pickled in the TASTy file but is elided in
the pickled quote pattern (same optimization already done later).

Fixes scala#18409
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 17, 2023
These trees where removed as part of an optimization. However, they
should be kept around to allow for better error messages and IDE navigation.

The type of the ascription in pickled in the TASTy file but is elided in
the pickled quote pattern (same optimization already done later).

Fixes scala#18409
nicolasstucki added a commit that referenced this issue Aug 17, 2023
These trees where removed as part of an optimization. However, they
should be kept around to allow for better error messages and IDE
navigation.

The type of the ascription in pickled in the TASTy file but is elided in
the pickled quote pattern (same optimization already done later).

Fixes #18409
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