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
add -Wconf flag for configurable warnings, @nowarn annotation for local suppression #8373
Merged
Commits on Mar 5, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 4f90f44 - Browse repository at this point
Copy the full SHA 4f90f44View commit details -
Configuration menu - View commit details
-
Copy full SHA for 2cf8e5c - Browse repository at this point
Copy the full SHA 2cf8e5cView commit details -
-Wconf compiler flag for configuring compiler 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 `since` version. Filtered warnings can be reported as error, warning, info, summary (like deprecations) or silent. Adds a `-rootdir` compiler 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. Unchecked warnings are now all shown by default (they were summarized like deprecations before). The `-deprecation`, `-feature` and `-unchecked` settings are no longer directly used in the compiler, they are shortcuts for specific `Wconf` configurations. The compiler only looks at `-Wconf`. Message filtering is performed in `global.currentRun.reporting`, not in the `Global.reporter`. The reasons are: - Separation of concerns: `Reporter`s worry about how to do reporting, removing duplicate messages. - Custom `Reporter`s are used by sbt, silencer, REPL, etc. It's too hard to do the necessary changes to the `Reporter` interface. - The `Wconf` setting could change between compiler runs. `currentRun.reporting` respects those changes. So all warnings in the compiler should go through `global.runReporting` (which is the same as `global.currentRun.reporting`). This method takes four parameters: pos, msg, category (new), site (new). The site is usually `context.owner` (in the frontend) or `currentOwner` (in transformations). `Context` has a `warn` method with 3 parameters (pos, msg, category) and inserts the `owner` as `site`, so this is used in the frontend (context reporters are also used to support silent mode / trying twice). The `global.warning` method is deprecated and no longer used. There are a few calls to `Reporter.warning` left in the codebase where no `runReporting` is reachable, I think they are all OK not to categorize / allow filtering. E.g., when running Scaladoc ``` reporter.warning(null, "Plugins are not available when using Scaladoc") ```
1Configuration menu - View commit details
-
Copy full SHA for 39d3b3a - Browse repository at this point
Copy the full SHA 39d3b3aView commit details -
Add
@nowarn
annotation for local warning suppressionIntegrate the fantastic [silencer](https://github.com/ghik/silencer) compiler plugin by @ghik into the compiler, which allows suppressing warnings locally using he `@nowarn` annotation. The `@nowarn` annotation suppresses warnings within the scope covered by the annotation. - `@nowarn def foo = ...`, `@nowarn class C { ... }` suppress warnings in a definition - `expression: @nowarn` suppress warnings in a specific expression The 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`. MiMa exception for addition of `scala.annotation.nowarn` Reporting warnings is now delayed until after typer, because the typer collects `@nowarn` annotations. If we stop before typer (e.g., because there are errors in the parser), all warnings are shown, even if they are enclosed in `@silent`. If a phase before typer has both errors and warnings, all errors are printed before the warnings.
Configuration menu - View commit details
-
Copy full SHA for 02bce3d - Browse repository at this point
Copy the full SHA 02bce3dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8d8222b - Browse repository at this point
Copy the full SHA 8d8222bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 60fcf45 - Browse repository at this point
Copy the full SHA 60fcf45View commit details -
Configuration menu - View commit details
-
Copy full SHA for 1489e59 - Browse repository at this point
Copy the full SHA 1489e59View commit details
Commits on Mar 6, 2020
-
Configuration menu - View commit details
-
Copy full SHA for 670a55c - Browse repository at this point
Copy the full SHA 670a55cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 251e4a5 - Browse repository at this point
Copy the full SHA 251e4a5View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.