[2.12] Configurable warnings (backported)#9248
Merged
dwijnand merged 28 commits intoscala:2.12.xfrom Oct 22, 2020
Merged
Conversation
Remove calls to System.exit/sys.exit outside of main methods. (cherry picked from commit 61abb61)
Complete the reporting refactor to use internal.Reporter. The partest blocker was fixed in v1.0.14. sbt and IDE are not validated, so reporters.Reporter is not removed. There are internal dependencies on cancel and comment functionality, which is resolved here by typecasing. Both features need to be implemented otherwise. ConsoleReporter is still a reporter.Reporter. (cherry picked from commit d59389e)
(cherry picked from commit e7389e0)
72faddc to
adf6a56
Compare
Let legacy Reporter handle adaptations. Reporter knows how to adapt new API and enforce maxerrs. The onus of supporting legacy reporter is on legacy reporter. Keep new reporters simple enough. Old reporters remain legacy reporters. Some tests expect to downcast to the reporter they assigned to `global.reporter`. Also avoid delegating to `NoReporter`. (cherry picked from commit e3b1e7c)
f247d42 to
6ee01f2
Compare
(cherry picked from commit 043c5ad)
The extended explanation attached to the first feature warning would fool the reporter if the feature is reported again at the same position. Use a conventional leading `"----"` to demarcate the explanation, and use only the prefix to see if the error has already been issued at a position. (cherry picked from commit 6a27388)
(cherry picked from commit 7ca0a7f)
This can be handy for retaining source compatibility. Or for when you just know better. Fixes scala/bug#8908 (cherry picked from commit ee18631)
(cherry picked from commit 9ced2d8)
ContextReporter no longer extends Reporter. The ContextReporter is only used in the context, and it reports through Global.reporter. But it's never assigned to Global.reporter. So better keep the two separate. This also saves the inherited fields (ContextReporters are allocated manies, type checking every Apply uses silent). Remove most reporter mixins to get to a linear inheritance structure, no more delegating reporters. Ignore the `force` parameter of `info0`. Some quirks to remain source compatible with the sbt compiler interface. `nsc.reporters.Reporter` only exists for sbt compatibility, Global has a `FilteringReporter`. `-Xreporter` must be a FilteringReporter. (cherry picked from commit 5f6b28c)
(cherry picked from commit b13d671)
(cherry picked from commit 3e7e0ab)
(cherry picked from commit 2cf8e5c)
47157d4 to
e0e3eab
Compare
This comment has been minimized.
This comment has been minimized.
c6a31d6 to
6b89537
Compare
lrytz
reviewed
Oct 21, 2020
Member
lrytz
left a comment
There was a problem hiding this comment.
Looked through the FIXMEs. I pushed a change for the ones in WConfTest, commented on the others.
lrytz
approved these changes
Oct 21, 2020
Member
lrytz
left a comment
There was a problem hiding this comment.
LGTM otherwise - I'm impressed how you pushed this through! I really didn't think this was feasible so cleanly and in such a short time, you proved me wrong 🙂
(cherry picked from commit 8d8222b)
(cherry picked from commit 60fcf45)
(cherry picked from commit 1489e59)
(cherry picked from commit 670a55c)
(cherry picked from commit 251e4a5)
- echo without Position parameter to ContextReporter, used in splain - StoreReporter.Info type/value aliases (scalameta, scapegoat) - make `info0` deprecatedOverriding instead of final (scalameta) (cherry picked from commit b5d951b)
Even though these warnings are emitted in the typer phase, the actual invocation is done at the end of type checking in the root context. So we should not use the `context.warning` method, as it injects `context.owner` as the warning site, which is always the root symbol. (cherry picked from commit a466056)
Previously, hasWarning meant a warning had been displayed (as opposed to counted). Since last refactor, it means counted, so warnings were summarized under -nowarn. Until 2.13.1, there was no summary under -nowarn. Let -nowarn mean -Xmaxwarns 0 (to mean show me no warnings) and additionally don't summarize any warnings (including erroring under -Werror). Named constants for Reporter.filter Test that suppression is relaxed in debug mode. Restore maxwarns after suppressing Scaladoc also touches nowarn ConsoleReporter respects nowarn, since PerRunReporting suppression mechanism has a checkpoint after typer, such that subsequent warnings are issued directly and therefore bump the warnings count. (cherry picked from commit 2a2f416)
If there is an error running a forked command, such as a Test or javac, log it instead of letting sbt swallow the exception. (It offers to let you run the last command to see the stack trace.) This helps if javac goes missing. (cherry picked from commit f342293)
Previously, a bad compiler option was ignored. Add a common idiom to StreamCapture to set stdout; the idiom may be suboptimal for testing. Convert a partest to junit for regex, and eliminate one check file. (cherry picked from commit 580ed07)
Remove withDefault. OutputSetting is StringSetting loosely coupled to outputDirs. MultiStringSetting takes a default Back out clearSetByUser, which worked around initialization of the setting. (cherry picked from commit 649fea5)
(cherry picked from commit 0c52dc4)
Backport from 01ea4f8
c3e9916 to
b14ba5d
Compare
Member
|
needs community build work: scala/community-build#1265 |
som-snytt
reviewed
Jan 19, 2021
| x + " works" | ||
| ^ | ||
| x + " works" | ||
| ^ |
Contributor
There was a problem hiding this comment.
Noticed that this is a regression. The text is supposed to align with text at prompt. I haven't checked the current head.
finaglehelper
pushed a commit
to twitter/finatra
that referenced
this pull request
Mar 11, 2021
Problem ======= Upgrade source to https://github.com/scala/scala/releases/tag/v2.12.13 from https://github.com/scala/scala/releases/tag/v2.12.12. This upgrade includes a highlighted feature of configurable warnings and errors (https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html / scala/scala#9248). Other noticable changes our code based will experience * Exhaustivity warnings for patterns involving tuples * Better type checking for `CharSequence` arguments scala/scala#9292 * Simplified Reporters scala/scala#8338 * Promotion of `-deprecation` to `-Xlint:deprecation` scala/scala#7714 * Improves performance of building `immutable.{TreeMap,TreeSet}` by using mutation within the builder scala/scala#8794 Full list of changes can be found at https://github.com/scala/scala/pulls?q=is%3Amerged+milestone%3A2.12.13+ Solution ======== * Bump `BUILD` file `SCALA_REV` && `SCALAC_REV_FOR_DEPS`. * Depdnencies which are not built for scala 2.12.13 needed to be bumped `SEMANTICDB_PLUGIN_REV` && `SEMANTICDB_REV` && `SCALAFIX_REV`. * Include `-S-Xlint:-deprecation` to `pants.ini` preventing build failures on deprecated annotations (existing behavior) * Bump `cache_key_gen_version` in `pants.ini` for newly built artifacts on different scala version. * Removed scalafix plugin (`scalac-profiling`) which is not built for 2.12.13. `scalac-profiling` code looks abandoned by ~3 years. * Updated all failing tests that could have depended or expected ordered sequences when the sequence was generated from non ordered collections. Notes ===== It seems a few tests and golden files in source have depended or tested against a stable sort order when sorted order is not guaranteed. This has been seen in a few places such as output json objects (map key fields), code that uses `groupBy` for rekeying results to the user and transforming into sequences, strings built from sequences or maps that are not guaranteed to be ordered. The following PR are related to this change in expectations scala/scala#8794 scala/scala#8948 scala/scala#9218 scala/scala#9376 scala/scala#9091 scala/scala#9216 We took the liberty updating tests with what the current map order would be or updating the test in a way that wouldn't depend on order. Since we may not fully understand all the context of the tests we are hoping this either signals to the owners that there might be some issue with assumed order or signal that upgrading might break implementations due to bug in scala 2.12.13. {D611202} will improve the files changed for workflow builder outside of this change. Please feel to reach out directly and discuss the changes here or bring up issues with this upgrade. Slack [[https://app.slack.com/client/T86S8GHEG/C01NZAFRLFK|#scala-upgrade-2-12-13]] JIRA Issues: SCALA-25 Differential Revision: https://phabricator.twitter.biz/D607826
hamzaremmal
pushed a commit
to hamzaremmal/scala3
that referenced
this pull request
May 2, 2025
hamzaremmal
pushed a commit
to scala/scala3
that referenced
this pull request
May 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Backport of:
Harden DisplayReporter against null messages #6920 Harden DisplayReporter against null messagesskipped, it's in "simplify reporters"Revert to using ConsoleReporter during spin up #6778 Revert to using ConsoleReporter during spin upshould have cherry-picked, but I realised after I'd basically manually copied this over while resolving the conflicts in cherry-picking "simplify reporters"@nowarnto use correct semantics for⍈ Fix@nowarnto use correct semantics for&REPL summarizes warnings #7756 REPL summarizes warningsnvm, deferred as it's more ergonomics than correctness