Skip to content

False positive unused given in extensions when referring to type alias #23250

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

Closed
WojciechMazur opened this issue May 23, 2025 · 0 comments · Fixed by #23256
Closed

False positive unused given in extensions when referring to type alias #23250

WojciechMazur opened this issue May 23, 2025 · 0 comments · Fixed by #23256
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

Similar to #23125 but this one still fails in main

Compiler version

Last good release: 3.7.0-RC1-bin-20250118-b801042-NIGHTLY
First bad release: 3.7.0-RC1-bin-20250227-1b0be01-NIGHTLY
Affects 3.7.0, 3.7.1-RC2
Bisect points to c65d45d

Minimized code

//> using options -Wunused:all -Werror

trait MonadError[F[_], E]
type MonadThrow[F[_]] = MonadError[F, Throwable]

trait MetaStreams[F[_]]:
  def use[A]: F[A] = ???
trait WriteResult

trait MetaStreamsSyntax:
  extension [F[_]](ms: MetaStreams[F])(using MonadThrow[F])
    def setMaxAge(): F[WriteResult] = 
      summon[MonadThrow[F]]
      ms.use[WriteResult]

    def setTruncateBefore(): F[WriteResult] =
      ms.use[WriteResult]

Output

[error] ./test.scala:13:46
[error] unused implicit parameter
[error]   extension [F[_]](ms: MetaStreams[F])(using MonadThrow[F])
[error]                                              ^

Expectation

Should not report unused MonadThrow

@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 May 23, 2025
@som-snytt som-snytt self-assigned this May 23, 2025
tgodzik pushed a commit that referenced this issue Jun 3, 2025
Fixes #23250 

The check for "unused implicit parameter" considers the type of the
parameter, but it should dealias first.

In addition, take an abstract type as not warnable, unless it has an
upper bound that is warnable (has non-universal members).

Note that `isSingleton` dealiases.

There was an ancient (OG) typo of `&` for `&&` which has gone unfixed
despite other edits. The right operand was always just an instanceof.
Not sure if the previous idiom saves an opcode, but now it looks like
other code nearby.
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.

2 participants