Add option -port to fsc

Option "port" limits compile server lookup and start to given port.
Normally fsc will start a compile server in a random port if no server
is yet running. This can be problematic with firewalls and/or remote
compile servers. Option "port" should not be confused with option
"server" which looks for a compile server in given host and port and
fails if such server is not found.

Automatic tests for command line user interface do not exist at all.
Thus, adding a test for one new option would require designing a whole
new testing method.
Let users specify a different location for build repos than user home

This change is helpful e.g. when setting up CI for Scala and it's important which directories are used by a build.
By default it uses .m2, .pax and .sbt/cache from user home (in general $HOME). Sometimes it's not possible to use
this location and also changing a value of $HOME is not an option.

The required location should be specified both for ant's build.xml and used scripts.
In the first case specifying -Duser.home is all, what we need. But we can't just set _JAVA_OPTIONS
as then partest tests fail due to the unexpected output (an additional 'Picked up java options (...)' messages).
We can set ANT_OPTS instead of this. The only problem was that OSGi JUnit tests (only they) were using $HOME anyway.
I forced them to use -Duser.home by propagating this option in build.xml.

binary-repo-lib.sh is changed to use a special env variable or $HOME, when this variable is not set.

Then we can do:

export SCALA_BUILD_REPOS_HOME=<some_dir>
export ANT_OPTS="$ANT_OPTS -Duser.home=$SCALA_BUILD_REPOS_HOME"
ant dist

and it will create all directories .m2, .pax and .sbt/cache in a specified $SCALA_BUILD_REPOS_HOME directory.

Note: maven's settings.xml should be located in this used $SCALA_BUILD_REPOS_HOME/.m2 and point to the
repository like <some_dir>/.m2/repository
SI-8981 Tweak REPL help

Tweak colon command processing.

Fixes an unhelpful message about the ambiguity of colon.
SI-8970  hashCode of BigDecimal and Double do not match

Switched isValidDouble (binary equivalence) to isDecimalDouble (decimal expansion equivalence), as people generally do not care about the slew of extra decimal digits off the end of the binary approximation to a decimal fraction (decimal equivalence is the standard now).

Added minimal unit test to verify behavior.
SI-8783  MultiMap documentation for addBinding is incorrect

Fixed documentation to state that addBinding will not replace a `value` that is equal (according to ==).
SI-8951  SeqView and StreamView stack-overflow on negative index after flatMap

Checks and throws IndexOutOfBounds now.

No test, caught and checked by scala-collections-laws (line 405 presently).
SI-6519  PagedSeq is not lazy enough

This was actually an issue with `length` of all things--it wasn't stopping scanning when it was past the end of what was requested.  It'd just gratuitously read everything.

Also fixed an overflow bug with isDefinedAt along the way (start + index > Int.MaxValue would always return true despite never working).
Fixes memory leak when using reflection

References to Threads would be retained long after their termination if
reflection is used in them. This led to a steady, long memory leak in
applications using reflection in thread pools.
SI-8695  SeqLike has unintuitive implementation of combinations

Clarified what `combinations` means in the docs.
SI-9003 Eagerly capture more potentially mutable binders

This is a re-run of SI-5158 in two different contexts.

As reported, the result of `unapply[Seq]` under name based pattern
matching might not guarantee stability of results of calls to
`_1`, `apply(i)`, etc, so we call these eagerly, and call them
once only.

I also found a case in regular pattern matching that we hadn't
accounted for: extracting elements of sequences (either from
a case class or from an `unapplySeq`) may also be unstable.

This commit changes `ExtractorTreeMaker` to force storage
of such binders, even under `-optimize`. This parallels the change
to `ProductExtractorTreeMaker` in 8ebe8e3e8.

I have added a special case for traditional `unapply` methods
returning `Option`. This avoids a change for:

```
% cat test/files/run/t9003b.scala
object Single {
  def unapply(a: Any) = Some("")
}

object Test {
  def main(args: Array[String]): Unit = {
    "" match {
      case Single(x) =>
        (x, x)
    }
  }
}
% qscalac -optimize -Xprint:patmat test/files/run/t9003b.scala 2>&1 | grep --context=5 get
      case <synthetic> val x1: Any = "";
      case5(){
        <synthetic> val o7: Some[String] = Single.unapply(x1);
        if (o7.isEmpty.unary_!)
          matchEnd4({
            scala.Tuple2.apply[String, String](o7.get, o7.get);
            ()
          })
        else
          case6()
      };
% scalac-hash v2.11.4 -optimize -Xprint:patmat test/files/run/t9003b.scala 2>&1 | grep --context=5 get
      case <synthetic> val x1: Any = "";
      case5(){
        <synthetic> val o7: Some[String] = Single.unapply(x1);
        if (o7.isEmpty.unary_!)
          matchEnd4({
            scala.Tuple2.apply[String, String](o7.get, o7.get);
            ()
          })
        else
          case6()
      };
```
Merge pull request #4148 from SpinGo/issue/SI-8946

SI-8946: Fixes memory leak when using reflection
SI-9006 Scaladoc: explicit companion and package links

The existing navigation mechanisms have proved hard to discover for newcomers
to Scaladoc.

This commit adds textual links in the navigation bar to the docs of the
companion (if defined) and to those of the enclosing package.
SI-8754  linear seqs aren't

LinearSeqLike still isn't exactly linear (LinearSeqOptimized is), but at least the docs now give reasonably correct information about what is actually going on.
Update ScalaDoc code examples not to use deprecated constructs

- Replace newTermName in favour of TermName
- Replace newTypeName in favour of TypeName
Merge pull request #4130 from mpociecha/let-specify-build-repos-home

Let users specify a different location for build repos than user home
Merge pull request #3934 from teemulehtinen/fsc-port-arg

FSC server port selected by argument
SI-9000  equals for immutable collections should check identity

`LinearSeqOptimized` now checks reference identity on `LinearSeq`s.

No unit test; this doesn't change visible behavior (save for side-effecting equals methods).
SI-8924 don't hold reference to list in iterator

Current implementation of LinearSeqLike.iterator holds
reference to complete sequence. This prevent garbage collecting
of List elements while we keep reference to iterator somewhere.

This commit removes reference from Iterator implementation. This
allow garbage collection of List while we iterating over its
elements (when there is no other references to List in our program).
SI-8946 Disable flaky test for reflection memory leak

It passed in PR validation but failed in a later run.
There are some clever ideas bouncing around to make it
stable, but in the meantime I'll shunt it into disabled.
Merge pull request #4170 from retronym/ticket/disable-8946

SI-8946 Disable flaky test for reflection memory leak