Skip to content

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented May 23, 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.

@som-snytt som-snytt force-pushed the issue/23250-warn-aliased-param-type branch from 047d302 to 17a1b3f Compare May 23, 2025 18:48
@som-snytt som-snytt marked this pull request as ready for review May 24, 2025 05:33
@Gedochao Gedochao requested a review from tgodzik May 29, 2025 14:58
trait ConfiguredCodec[T]
object ConfiguredCodec:
inline final def derived[A](using conf: Configuration)(using inline mirror: Mirror.Of[A]): ConfiguredCodec[A] = // warn // warn
inline final def derived[A](using conf: Configuration)(using inline mirror: Mirror.Of[A]): ConfiguredCodec[A] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These warning seemed valid, neither mirror nor conf is actually used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Mirror doesn't have terms to use. Also Of is an alias so warned previously.

@som-snytt som-snytt force-pushed the issue/23250-warn-aliased-param-type branch from 17a1b3f to c052463 Compare May 31, 2025 03:51
@som-snytt
Copy link
Contributor Author

Tweaked to use hiBound, which simplifies but maybe a hair less efficient.

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tgodzik tgodzik merged commit 2d18655 into scala:main Jun 3, 2025
29 checks passed
@som-snytt som-snytt deleted the issue/23250-warn-aliased-param-type branch June 3, 2025 15:12
@WojciechMazur WojciechMazur added this to the 3.7.2 milestone Jun 18, 2025
tgodzik pushed a commit to scala/scala3-lts that referenced this pull request Jun 19, 2025
Fixes scala#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.
[Cherry-picked 2d18655]
tgodzik pushed a commit to scala/scala3-lts that referenced this pull request Jun 20, 2025
Fixes scala#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.
[Cherry-picked 2d18655]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

False positive unused given in extensions when referring to type alias

3 participants