Skip to content

Add suppression if nowarn differs #23652

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

Merged
merged 5 commits into from
Aug 6, 2025
Merged

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Aug 2, 2025

Fixes #23651

The previous fix for the same @nowarn attached to multiple elements should have compared the annotPos to identify duplicates (instead of the target range).

This commit defers detecting "bad" or duplicate suppressions (which originate with the same annotation) to report time, after the suppression is "unused"; there are few nowarns per file and fewer that are unused.

While checking for a suppression, mark matching unused suppressions as "superseded", so that if they remain unused, the warning can add an "audit" that the nowarn matched a diagnostic (but was superseded by some other nowarn).

This commit goes further and checks for duplicates (including whether the filters look the same).

If it finds a duplicate where the annotPos differs, warn about the user-written annotation.

Filters match each other if they are the same type and, if they have a pattern, the string representations of the patterns are equal.

@som-snytt
Copy link
Contributor Author

Not sure why runFinished avoided taking a context, or where it closed over ctx.

@som-snytt som-snytt marked this pull request as ready for review August 2, 2025 18:01
@Gedochao Gedochao requested review from mbovel and tgodzik August 4, 2025 05:20
@Gedochao Gedochao added the backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. label Aug 4, 2025
@WojciechMazur WojciechMazur added this to the 3.7.3 milestone Aug 4, 2025
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!

@Gedochao Gedochao merged commit 40843f7 into scala:main Aug 6, 2025
45 checks passed
@som-snytt som-snytt deleted the issue/23651-nowarn branch August 6, 2025 13:54
tgodzik pushed a commit to scala/scala3-lts that referenced this pull request Aug 8, 2025
Fixes scala#23651

The [previous fix](scala#22383) for the
same `@nowarn` attached to multiple elements should have compared the
`annotPos` to identify duplicates (instead of the target range).

This commit defers detecting "bad" or duplicate suppressions (which
originate with the same annotation) to report time, after the
suppression is "unused"; there are few nowarns per file and fewer that
are unused.

While checking for a suppression, mark matching unused suppressions as
"superseded", so that if they remain unused, the warning can add an
"audit" that the nowarn matched a diagnostic (but was superseded by some
other nowarn).

~This commit goes further and checks for duplicates (including whether
the filters look the same).~

~If it finds a duplicate where the `annotPos` differs, warn about the
user-written annotation.~

~Filters match each other if they are the same type and, if they have a
pattern, the string representations of the patterns are equal.~
tgodzik added a commit to scala/scala3-lts that referenced this pull request Aug 8, 2025
Fixes scala#23651 

The [previous fix](scala#22383) for the
same `@nowarn` attached to multiple elements should have compared the
`annotPos` to identify duplicates (instead of the target range).

This commit defers detecting "bad" or duplicate suppressions (which
originate with the same annotation) to report time, after the
suppression is "unused"; there are few nowarns per file and fewer that
are unused.

While checking for a suppression, mark matching unused suppressions as
"superseded", so that if they remain unused, the warning can add an
"audit" that the nowarn matched a diagnostic (but was superseded by some
other nowarn).

~This commit goes further and checks for duplicates (including whether
the filters look the same).~

~If it finds a duplicate where the `annotPos` differs, warn about the
user-written annotation.~

~Filters match each other if they are the same type and, if they have a
pattern, the string representations of the patterns are equal.~
[Cherry-picked 40843f7][modified]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

multiple @nowarn annotation does not work since Scala 3.7.0
5 participants