Merge pull request #3284 from soc/SI-7880

SI-7880 Fix infinite loop in ResizableArray#ensureSize
Merge pull request #3313 from OlivierBlanvillain/upstream

Fix typos in documentation
SI-8058 Better support for enum trees

Replace the approach of “detect some magic combination of flags to
trigger some action” by introducing an enum flag which makes the
semantics and the intentions of the code using it more explicit.

This basically involves wiring up the existing ACC_ENUM bit to a new
modifier flag and making sure it is set correctly when encountering
enums.

The existing enum tests files/pos/t5165 and files/pos/t2764 keep
working, showing that this hasn't introduced any obvious regressions.

Tests for the changes in Namer which prevent scalac from messing with
enum trees can't be added yet, because one currently can't define an
enum in Scala without the help of the macro paradise.
The intention is to add the @enum macro as a full test suite as soon
as one can depend on macro annotations.

One might wonder why we don't check for
    clazz.superClass == JavaEnumClass (where clazz is the owning class)
in isEnumConstant.

The reason is that this causes illegal cyclic reference error.

Explanation by Eugene why this happens:

(23:17:52) xeno_by: so here's what happens as far as I can understand at 11pm :)
(23:18:09) xeno_by: scalac tries to complete the signature of the newly expanded class
(23:18:11) xeno_by: to do that
(23:18:40) xeno_by: to do that it needs three things
(23:18:51) xeno_by: because the signature of a class is ClassInfoType which consists of three things
(23:19:05) xeno_by: parents
(23:19:08) xeno_by: decls
(23:19:09) xeno_by: and symbol
(23:19:20) xeno_by: symbol is easy - it's already there
(23:19:30) xeno_by: parents are also easy
(23:19:39) xeno_by: you just typecheck the things that come after "extends"
(23:19:42) xeno_by: but decls are tricky
(23:19:51) xeno_by: scalac goes through all the members of the class
(23:20:03) xeno_by: and doesn't typecheck them... no, it doesn't
(23:20:07) xeno_by: it just enters them
(23:20:32) xeno_by: i.e. creates symbols for them and assigns lazy completers to those symbols so that if someone wants to know their signatures, they will go through the completers
(23:20:34) xeno_by: and then
(23:20:38) xeno_by: wait
(23:20:40) xeno_by: there's one but
(23:20:42) xeno_by: BUT
(23:20:47) xeno_by: while we enter those symbols
(23:20:53) xeno_by: our ClassInfoType is not ready yet
(23:21:09) xeno_by: the class we're completing is still considered to be in the middle of being completing
(23:21:12) xeno_by: so
(23:21:24) xeno_by: when inside enterSym you try to ask that class for its super class
(23:21:35) xeno_by: what happens is that check asks the class for its type signature
(23:21:45) xeno_by: the ClassInfoType that consists of parents and decls
(23:21:54) xeno_by: even though the parents are already calculated
(23:22:01) xeno_by: the ClassInfoType as a whole is not
(23:22:16) xeno_by: so scalac says that you're trying to complete something that's currently being completed
(23:22:20) xeno_by: cyclic reference error
(23:22:59) xeno_by: "cyclic" in English looks an awful lot like "суслик" in Russian (which means "gopher")
Removes TODO comments that are no longer applicable

- we do not want to use mutable updates because that would mean making vals
vars, losing various guarantees for final fields of the java memory model

- we do not want to add more subcasses of HashSet, because that would make
callsites megamorphic. If anything, we should try to reduce the number of
subclasses

- checking for monomorphic call site is not worth it for a single virtual
method call.
toCode is added to Printers

1. Printers API is updated (def toCode)
2. ParsedTreePrinter is added to internal.Printers. ParsedTreePrinter generates the code for passed unattributed trees.
Generated code can be later compiled by scalac retaining the same meaning.
Tests for ParsedTreePrinter
Printers code refactoring and cleanup
SI-6563 Test case for already-fixed crasher

Progressed to working in SI-7636 / c4bf1d5.
SI-8111 Repair symbol owners after abandoned named-/default-args

Names/Defaults eagerly transforms an application with temporaries
to maintain evaluation order, and dutifully changes owners of
symbols along the way.

However, if this approach doesn't work out, we throw away this
and try a auto-tupling. However, we an still witness symbols
owned by the temporaries.

This commit records which symbols are owned by the context.owner
before `transformNamedApplication`, and rolls back the changes
before `tryTupleApply`.

Perhaps a better approach would be to separate the names/defaults
applicability checks from the evaluation-order-preserving transform,
and only call the latter after we have decided to go that way.
Merge pull request #3329 from retronym/ticket/6563

SI-6563 Test case for already-fixed crasher
SI-8102 -0.0.abs must equal 0.0

SI-8102 points out that -0.0.abs returns -0.0 (in error). The same issue
exists for -0.0f. This commit fixes the issue for both by delegating to
math.abs.
Annotated trees processing is modified

1. Problem with multiple parameter lists in annotations is resolved
2. Tests for Annotated trees are added
Code cleanup based on pull request comments
SI-8120 Avoid tree sharing when typechecking patmat anon functions

When typechecking an empty selector `Match` corresponding to:

    { case ... => ... }: (A => B)

We wrap it in a `Function` and typecheck:

    (x$1 => x$1 match { case ... => ... })

Local symbols in this expression (representing values bound by
the pattern, or just definitions in the body or guard) are then
owned by the anonymous function's symbol.

However, if we ever discard this `Function` and start anew with
the empty selector match, as happens during the fallback to
use a view on the receiver in `tryTypedApply`, we found that we
had mutated the cases of the original tree, and allowed orphaned
local symbols to escape into the compiler pipeline.

This commit uses duplicated trees for the the cases in the synthetic
`Match` to avoid this problem.

`duplicateAndKeepPositions` is used to preserve range positions;
without this scala-refactoring PrettyPrinterTest fails.
`Tree#duplicate` uses offset positions in the copied tree, which
is appropriate when both the original and the copy are going to end up
in the final tree.
awakens default getter synthesis from the untyper nightmare

Our happy little macro paradise is regularly invaded by resetAllAttrs,
the bane of all macros and typers. It’s so ruthless and devastating that
we’ve been long scheming to hack something really cool and to one day
defeat it.

Today we make the first step towards the happy future. Today we overthrow
the UnTyper, resetAllAttrs’s elder brother that rules in the kingdoms of
GetterLand and CaseClassia, and banish him from the land of getters.
In the name of what’s good and meta, let’s band together and completely
drive him away in a subsequent pull request!

To put it in a nutshell, instead of using untyper on a DefDef to do
default getter synthesis, the commit duplicates the DefDef and does
resetLocalAttrs on it.

As default getter synthesis proceeds with figuring out type and value
parameters for the getter, then its tpt and finally its rhs, the commit
destructures the duplicated DefDef and then assembles the default getter
from the destructured parts instead of doing copyUntyped/copyUntypedInvariant
on the original DefDef.

I would say the test coverage is pretty good, as I had to figure out
3 or 4 test failures before I got to the stage when everything worked.
Iirc it tests pretty exotic stuff like polymorphic default parameters
in both second and third parameter lists, so it looks like we're pretty
good in this department.
untyper is no more

Unlike with default getters, removing untyper from case class synthesis
was trivial. Just resetLocalAttrs on a duplicate of the provided class def,
and that’s it.

resetAllAttrs, you’re next. We’ll get to you! Eventually...
ExistentialTypeTree.whereClauses are now MemberDefs

Today’s flight back to Lausanne wasn’t as productive as the recent flight
to Minsk (https://github.com/scala/scala/pull/3305), but I noticed
one minor thingie: ExistentialTypeTree had an imprecise type specified
for its whereClauses. This is now fixed.

I didn’t increment PickleFormat.*Version numbers, because this change
introduces only a miniscule incompatibility with what would have been
a meaningless and most likely crash-inducing pickle anyway.
License formatting tweak, RTF version.

To avoid duplication in scala/scala-dist, where it'll just go stale.
SI-4841 CLI help update for -Xplugin

The argument to `-Xplugin` is now a comma-separated list of paths.
This commit updates the option descriptor and a code comment.
Fixes #3330 with Scaladoc changes only