Commit Graph

36145 Commits

Author SHA1 Message Date
Viktor Klang a5fb116dbf Revert ExecutionContext.global to not be a BatchingExecutor 2020-10-23 11:59:56 +01:00
Dale Wijnand 59c6eda13c
Merge pull request #9269 from dwijnand/library-disable-fatal-warnings
Disable fatal warnings in the library
2020-10-23 11:56:53 +01:00
Dale Wijnand 239bf73fdf Disable fatal warnings in reflect
... in order to land this PR as well as the exhaustivity improvements PR.
2020-10-23 11:16:24 +01:00
Dale Wijnand 1cc0a05e39
Merge pull request #9264 from SethTisue/readme-nightlies
update nightly build information in README.md
2020-10-23 10:54:14 +01:00
Dale Wijnand 6a5b2d975c Disable fatal warnings in the library
The fatal warnings PR (for library) was merged prematurely as it is
impacting my exhaustivity PR.  Rather do anything (like rebase or tweak)
to the 12 commits that my PR consists of and therefore causing CI to
rebuild each commit, I'm separately going to PR disabling fatal
warnings, so I can merge my PR without it instantly breaking the 2.13.x
branch.

I'll do the same for the reflect and compiler PRs, and once we've
re-STARR'd we can re-enable fatal warnings by either resolving all the
exhaustivity warnings or opting out of them (or a mix of both).
2020-10-23 09:47:50 +01:00
Dale Wijnand 4ef23e4056 Avoid spurious custom extractor warnings
The pattern matcher converts code like:

    Box(Option("hello")) match {
      case Box(Some(s)) =>
      case Box(None)    =>
    }

into two invocations of Box.unapply, because it can't trust that
Box.unapply is idempotent.  For case classes (like Some) it can, and
moreso it can just access the underlying values directly ("x1.value").
The exhaustivity/unreachability analysis builds on this (e.g
"pointsToBound.exists(sym => t.exists(_.symbol == sym)").

With the previous commits making the exhaustivity/unreachability checker
consider custom extractors this would result in multiple symbols for
each extraction (instead of all being "x1.value", for example) which
results in multiple SAT variables which results, basically, in  warnings
that the value returned from the first extraction could None and the
second value could be Some - which is only true for a non-idempotent
Box.unapply.  The intent of the previous commits (and the whole PR) is
to make the exhaustivity checker provide warnings that were previous
missing, but warning for fear of non-idempotent custom extractors would
produce more noise than signal.

Now, within a minor release like 2.13.4 we can't go and change the code
generation and thus the code semantics (Dotty can and apparently does),
but we can do the analysis with the assumption of idempotency.  That's
what this does: in MatchApproximator's TreeMakersToProps use a cache for
the binders so when we see two extractions that are equivalent we reuse
the same binder, so it translates into the same SAT variable.
2020-10-23 00:12:53 +01:00
Dale Wijnand 0416c57a01 Reverse -Xlint:strict-unsealed-patmat into -Xno-unsealed-patmat-analysis 2020-10-23 00:12:53 +01:00
Seth Tisue 1f28ba65d8 language spec: document the un-updated status of the changelog 2020-10-22 13:11:51 -07:00
Seth Tisue 8d3b2ca240 update nightly build information in README.md
fixing the issue reported at
https://contributors.scala-lang.org/t/coming-soon-scala-2-13-4/4555/2

this also removes the bit about nightly Scaladoc, since that
stopped in 2018 afaict
2020-10-22 12:53:31 -07:00
Dale Wijnand 9c75e62858
Merge pull request #9262 from dwijnand/2.13/opt-ListMap-foldRight
ListMap is reverse oriented, so use that for foldRight (forward-port)
2020-10-22 15:52:38 +01:00
Lukas Rytz 2ab9556e9a
[nomerge] Merge pull request #9260 from dwijnand/mima
Update MiMa & add exclusions for new trait overrides
2020-10-22 14:59:04 +02:00
mkeskells 82502c5a27 ListMap is reverse oriented, so use that for foldRight
(cherry picked from commit 2103368a92)
2020-10-22 12:25:41 +01:00
Dale Wijnand 8580a5c968 Update MiMa & add exclusions for new trait overrides 2020-10-22 11:57:03 +01:00
Dale Wijnand 7577c7ac31
Merge pull request #9259 from lrytz/t12096 2020-10-22 11:47:05 +01:00
Dale Wijnand 698fa73137
Merge pull request #9246 from bjornregnell/fix_undeprecate_useful_StringOps
fixes scala/bug #11676 un-deprecate useful StringOps operations
2020-10-22 11:38:36 +01:00
Dale Wijnand 6e96b92df4
Merge pull request #9251 from seratch/issue-12065 2020-10-22 11:34:16 +01:00
Dale Wijnand 4b8eea0c95
Merge pull request #9249 from mshibuya/issue/12176 2020-10-22 11:33:11 +01:00
Dale Wijnand d7edb38b39
Merge pull request #9256 from som-snytt/tweak/old-quotes 2020-10-22 11:25:54 +01:00
Dale Wijnand 262f5f2f53
Merge pull request #9248 from dwijnand/2.12/conf-warnings 2020-10-22 11:09:40 +01:00
Lukas Rytz e79b6efd51 Never elide fields for `private[this] var` class parameters
After the previous commit, the field for a `private[this] var` class
parameter is only elided if the field is not used at all. This seems
not to be worth the effort.
2020-10-22 11:28:59 +02:00
Lukas Rytz a93ebdd737 Keep `private[this] var` class parameter fields that are only read
Reads of `var` class parameters in the constructor are not rewritten to
the constructor parameter, they keep referring to the field to ensure
potential field writes are reflected (this was fixed in #7688).

This means that the corresponding field cannot be elided even if it's
never written.

The alternative solution would be to detect `private[this] var` fields
that are only read in the constructor. However this is difficult to
implement, see #9143.
2020-10-22 11:28:52 +02:00
Lukas Rytz 7f6b956e1a
Merge pull request #9255 from som-snytt/issue/12195 2020-10-22 11:08:58 +02:00
Princess | April 9a716985fc
Merge pull request #9174 from NthPortal/topic/mutation-tracking-iterators/PR
[bug#12009] Make ListBuffer's iterator fail-fast
2020-10-21 22:30:52 -04:00
Jason Zaugg 95a569bf8e
Merge pull request #8794 from mkeskells/2.12.x_RedBlackMutable
RedBlackTree with fast mutable builder [ci: last-only]
2020-10-22 11:22:13 +10:00
Jason Zaugg cdfcf96394 Further performance improvements to groupBy
- Special case result sizes of 0-4 and avoid mutable.HashMap
    allocation.
  - Expose entriesIterator through a private[collection] method,
    rather than via subclassing, to avoid changing the JIT
    of code using mutable.HashMap that might currently rely on
    Class Heirarchy Analysis noticing that it effectively final.
  - Fuse some lambdas into `object grouper`.
2020-10-22 10:37:42 +10:00
Jason Zaugg 21a473bcfc Reduce allocations in groupBy
- Avoid lambda allocation in getOrElseUpdate call
  - Avoid intermediate Tuple2 instances when iterating through
    the mutable map.
  - Avoid allocating Map1-4 during building the result if
    the size of the grouped exceeds 4. Intead build a HashMap
    directly.

```
./benchdb list --limit 2 && ./benchdb results --run 5 --run 6 --pivot size  && ./benchdb results --run 5 --run 6 --pivot size --metric "·gc.alloc.rate.norm"
┏━━━━┳━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Timestamp           ┃ Msg              ┃
┣━━━━╋━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━━━┫
┃  6 ┃ 2020-08-24 07:14:36 ┃ PR 8948          ┃
┃  5 ┃ 2020-08-24 07:06:47 ┃ PR 8948 Baseline ┃
┗━━━━┻━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━┛
2 test runs found (limit reached).
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━┳━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━┓
┃                                                (size) ┃                ┃                ┃      ┃     ┃        128         ┃         512         ┃         2048          ┃         8192          ┃       ┃
┃ Benchmark                                             ┃ (hashCodeCost) ┃ (maxNumGroups) ┃ Mode ┃ Cnt ┃    Score ┃   Error ┃     Score ┃   Error ┃      Score ┃    Error ┃      Score ┃    Error ┃ Units ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━╋━━━━━━━━━━╋━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━╋━━━━━━━┫
┃ #5:scala.collection.GroupByBenchmark.buildArrayBuffer ┃             32 ┃              8 ┃ avgt ┃  30 ┃ 8631.963 ┃ 116.790 ┃ 30969.939 ┃ 456.711 ┃ 119820.013 ┃ 1741.671 ┃ 480813.306 ┃ 7268.723 ┃ ns/op ┃
┃ #6:scala.collection.GroupByBenchmark.buildArrayBuffer ┃             32 ┃              8 ┃ avgt ┃  30 ┃ 8287.717 ┃ 135.038 ┃ 30672.551 ┃ 540.409 ┃ 119356.530 ┃ 1592.624 ┃ 477570.346 ┃ 6365.010 ┃ ns/op ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━┻━━━━━━┻━━━━━┻━━━━━━━━━━┻━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━┛
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━┳━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━┳━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━┳━━━━━━━┓
┃                                                (size) ┃                ┃                ┃      ┃     ┃       128        ┃        512        ┃        2048        ┃        8192        ┃       ┃
┃ Benchmark [·gc.alloc.rate.norm]                       ┃ (hashCodeCost) ┃ (maxNumGroups) ┃ Mode ┃ Cnt ┃    Score ┃ Error ┃     Score ┃ Error ┃     Score ┃  Error ┃      Score ┃ Error ┃ Units ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━╋━━━━━━━━━━━━━━━━╋━━━━━━╋━━━━━╋━━━━━━━━━━╋━━━━━━━╋━━━━━━━━━━━╋━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━╋━━━━━━━━━━━━╋━━━━━━━╋━━━━━━━┫
┃ #5:scala.collection.GroupByBenchmark.buildArrayBuffer ┃             32 ┃              8 ┃ avgt ┃  30 ┃ 2192.014 ┃ 0.022 ┃ 13712.051 ┃ 0.076 ┃ 50949.533 ┃ 56.381 ┃ 198544.803 ┃ 1.213 ┃ B/op  ┃
┃ #6:scala.collection.GroupByBenchmark.buildArrayBuffer ┃             32 ┃              8 ┃ avgt ┃  30 ┃ 1896.014 ┃ 0.021 ┃  5224.051 ┃ 0.077 ┃ 17768.204 ┃  0.305 ┃  67176.786 ┃ 1.180 ┃ B/op  ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━┻━━━━━━━━━━━━━━━━┻━━━━━━┻━━━━━┻━━━━━━━━━━┻━━━━━━━┻━━━━━━━━━━━┻━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━┻━━━━━━━┛
```
2020-10-22 10:37:05 +10:00
Jason Zaugg 3f60deba69 Benchmark for groupBy 2020-10-22 10:37:05 +10:00
Som Snytt 71bce77a19 Use unmixed backticks more uniformly 2020-10-21 16:44:39 -07:00
NthPortal 8f6e522778 [bug#12009] Make ListBuffer's iterator fail-fast
Make `ListBuffer`'s iterator fail-fast when the buffer is
mutated after the iterator's creation.

Co-authored-by: Jason Zaugg <jzaugg@gmail.com>
2020-10-21 16:35:35 -04:00
NthPortal 1390315b03 [bug#3088][bug#12121] Fix adding/subtracting ListBuffer to/from itself
Fix appending a `ListBuffer` to itself and subtracting
a `ListBuffer` from itself.

Fix appending a `Growable` that uses the default
`addAll` implementation to itself.
2020-10-21 16:35:33 -04:00
Som Snytt 2878d88fca Additional regression test 2020-10-21 13:05:53 -07:00
Som Snytt 8e2f16e0ab Java imports compete with level 4 definitions
Like Scala, an import in Java can shadow a definition
in another file, if it is not import-on-demand.

The implementation bailed too quickly from searching
enclosing contexts while testing this condition.
2020-10-21 09:05:03 -07:00
Lukas Rytz b14ba5d77d Backport -Xlint:deprecation
Backport from 01ea4f8bc2
2020-10-21 16:32:43 +01:00
Som Snytt ffef4d32aa All filters must match for nowarn
(cherry picked from commit 0c52dc4636)
2020-10-21 16:32:42 +01:00
Som Snytt 031eb16dde BooleanSetting takes a default
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 649fea5d13)
2020-10-21 16:32:42 +01:00
Som Snytt 37d54cc58b DirectTest checks compiler options
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 580ed0706d)
2020-10-21 16:32:42 +01:00
Som Snytt 8cb1dd6cd3 Partest logs fork errors
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 f34229300d)
2020-10-21 16:32:42 +01:00
Som Snytt 1afdb3cb6c Warning summary respects -nowarn
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 2a2f4169ca)
2020-10-21 16:32:42 +01:00
Lukas Rytz b60e48d852 Fix warning site for unused warnings
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 a466056367)
2020-10-21 16:32:42 +01:00
Lukas Rytz 88db906c07 More source compatibility tweaks for reporters
- 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 b5d951be1e)
2020-10-21 16:32:42 +01:00
Lukas Rytz c6dbbaa974 use full path in site and origin strings
(cherry picked from commit 251e4a58b1)
2020-10-21 16:32:42 +01:00
Lukas Rytz ec5fc017ee support -Wconf in repl
(cherry picked from commit 670a55c453)
2020-10-21 16:32:42 +01:00
Lukas Rytz eb724b580e empty filter is no filter
(cherry picked from commit 1489e59716)
2020-10-21 16:32:42 +01:00
Lukas Rytz 143ba48d6c better Wconf doc
(cherry picked from commit 60fcf4562f)
2020-10-21 16:32:42 +01:00
Lukas Rytz ea241b1bcd fix some warning categories
(cherry picked from commit 8d8222b55d)
2020-10-21 16:32:42 +01:00
Lukas Rytz ec8f9de10c 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.

(cherry picked from commit 02bce3d609)
2020-10-21 16:32:42 +01:00
Lukas Rytz 288da0f1e8 -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")
```

(cherry picked from commit 39d3b3a93c)
2020-10-21 16:03:48 +01:00
Lukas Rytz 9faf48bd7a
Merge pull request #9254 from joroKr21/gadt-cce
Use correct tree for child unapply context
2020-10-21 13:29:34 +02:00
Mitsuhiro Shibuya d47ea5bf70
Test remove(Int) and remove(Int, Int) separately
as suggested here:
https://github.com/scala/scala/pull/9249#discussion_r508456058

Co-authored-by: Diego E. Alonso Blas <diesalbla@gmail.com>
2020-10-21 16:34:57 +09:00
Georgi Krastev 31a3f9921f Use correct tree for child unapply context
Prevents `ClassCastException` in some GADT scenarios
and makes valid code compile in others.

The parent context tree could be the case def itself.
In that case creating a child context with the same tree
breaks the logic to restore saved type bounds in `typedCase`,
because `enclosingCaseDef` returns the child instead of the parent.
This leads to saving modified bounds in the child context
but later trying and failing to restore them in the parent context.

The leaked bounds later cause type errors in the best case
or propagate incorrect information to erasure in the worst case.

Using the tree of the unapply itself for the child context
means that `enclosingCaseDef` will return the parent context.
2020-10-21 04:55:10 +02:00