-
Notifications
You must be signed in to change notification settings - Fork 3.1k
add -Wconf flag for configurable warnings, @nowarn annotation for local suppression #8373
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
Conversation
|
Message filtering is performed in The reasons are:
So all warnings in the compiler should go through
The There are a few calls to |
|
Added support for local warning suppression using |
|
This will be immensely useful. Thanks for working on this! |
7729d15 to
9c37e5e
Compare
|
Removed the WIP flag and update the PR description, this is ready to be reviewed! |
174a43e to
8aa1750
Compare
|
@SethTisue would you be interested to review this, at least on a high level? I updated the PR description, and also included a section on significant changes. |
f2ed6db to
1667f83
Compare
|
@lrytz Thanks for the quick response.
I got |
|
OK, I see how the The following command line worked as expected for me: |
|
@lrytz I investigated more and I found the issue. I got a bit unlucky and the first warning I tried to suppress didn't seem to have the
In the Kafka codebase, we had one other example like the above (similar pattern), but all other ones worked fine. The usage of |
|
I'll take a look if I can reproduce and fix that. For |
|
(moved my comment to scala/scala-collection-compat#312 (comment) where I intended to post it) |
|
Thanks! |
|
|
|
@charpov https://github.com/scala/scala/blob/v2.13.3/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala#L1046 just says other. (Probably I'd ask on gitter instead of the old PR.) (or the forum. It might be a useful topic to consider what cats are useful.) |
add -Wconf flag for configurable warnings, @nowarn annotation for local suppression
add -Wconf flag for configurable warnings, @nowarn annotation for local suppression

This PR adds a
-Wconfcompiler flag that allows filtering and configuring compiler warnings (silence them, or turn them into errors).It also integrates the fantastic silencer compiler plugin by @ghik into the compiler, which allows suppressing warnings locally using the
@nowarnannotation.Configurable Warnings
Warnings are assigned a category.
Warnings can be filtered by category, by message regex, by site where they are issued, and by source path. Deprecations can additionally be filtered by origin (deprecated definition) and
sinceversion.Filtered warnings can be reported as error, warning, info, summary (like deprecations) or silent.
Local Suppression
The
@nowarnannotation suppresses warnings within the scope covered by the annotation.@nowarn def foo = ...,@nowarn class C { ... }: suppress warnings in a definitionexpression: @nowarn: suppress warnings in a specific expressionThe annotation can be configured to filter selected warnings, for example
@nowarn("cat=deprecation")only suppresses deprecation warnings. The filter configuration syntax is the same as in-Wconf.Help Text
Significant changes
scala.annotation.nowarn-rootdircompiler flag. It is used to relativize file paths when using source filters (-Wconf:src=some/source/File.scala:s), there might be other uses for it in the future.warningmethods in currentRun.reporting and context reporter take newCategoryparameter. Theglobal.reporteris unchanged, warnings reported through it are not filtered byWconf.@nowarnannotations.@nowarn-deprecation,-featureand-uncheckedsettings are no longer directly used in the compiler, they are shortcuts for specificWconfconfigurations. the compiler only looks at-Wconf.