Skip to content
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
merged 9 commits into from Mar 9, 2020

Commits on Mar 5, 2020

  1. gitignore for metals

    lrytz committed Mar 5, 2020
    Configuration menu
    Copy the full SHA
    4f90f44 View commit details
    Browse the repository at this point in the history
  2. minor cleanups

    lrytz committed Mar 5, 2020
    Configuration menu
    Copy the full SHA
    2cf8e5c View commit details
    Browse the repository at this point in the history
  3. -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")
    ```
    lrytz committed Mar 5, 2020
    1 Configuration menu
    Copy the full SHA
    39d3b3a View commit details
    Browse the repository at this point in the history
  4. Add @nowarn annotation for local warning suppression

    Integrate 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.
    lrytz committed Mar 5, 2020
    Configuration menu
    Copy the full SHA
    02bce3d View commit details
    Browse the repository at this point in the history
  5. fix some warning categories

    lrytz committed Mar 5, 2020
    Configuration menu
    Copy the full SHA
    8d8222b View commit details
    Browse the repository at this point in the history
  6. better Wconf doc

    lrytz committed Mar 5, 2020
    Configuration menu
    Copy the full SHA
    60fcf45 View commit details
    Browse the repository at this point in the history
  7. empty filter is no filter

    lrytz committed Mar 5, 2020
    Configuration menu
    Copy the full SHA
    1489e59 View commit details
    Browse the repository at this point in the history

Commits on Mar 6, 2020

  1. support -Wconf in repl

    lrytz committed Mar 6, 2020
    Configuration menu
    Copy the full SHA
    670a55c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    251e4a5 View commit details
    Browse the repository at this point in the history