SI-5767 fix + small HashSet/HashMap fixes

- `LinkedHashSet` implementation moved from `FlatHashTable` to `HashTable`
   - `remove` time reduced from O(n) to O(1)
   - `diff` time reduced from O(n^2) to O(n)
- A bit of refactoring in `HashTable` serialization code
- Putting an element into hash map now avoids double hash code/hash index
  calculation (see `HashTable#findOrAddEntry`)
- bugfix: compiler/LambdaLift occasionally breaks LinkedHashSet integrity
Rank based take/drop/slice.

Tree navigation based on node rank is faster than using compare
method. rank is simply count(tree.left) + 1.
Making public methods of FlatHashTable protected

As discussed in https://groups.google.com/forum/?pli=1#!topic/scala-internals/1yABM30POS0
test suite for SI-6329
SI-6331 Avoid typing an If tree with a constant type.

The fast path in typedIf added in 8552740b avoided lubbing the if/else branch types
if they are identical, but this fails to deconst the type. This could lead to the entire
if expression being replaced by a constant.

Also introduces a new tool in partest for nicer checkfiles.

// in Test.scala
trace(if (t) -0d else 0d)

// in Test.check
trace> if (Test.this.t)
  -0.0
else
  0.0
res: Double = -0.0
Refine equality of Constant types over floating point values.

The constant types for 0d and -0d should not be equal.

This is implemented by checking equality of the result of
doubleToRawLongBits / floatToRawIntBits, which also correctly
considers two NaNs of the same flavour to be equal.

Followup to SI-6331.
Test for consistency of Constant#{equals, hashCode}.

For the examples I've constructed, they are consistent, but
I put this down to good luck, rather than good management.
The next commit will address this.
Improve Constant#hashCode

 - Incorporate `tag`, which is considered by equals, to reduce collisions.
 - Use the result of floatToRawIntBits(value) / doubleToRawLongBits(value),
    rather than value. This wasn't strictly necessary as (0d.## == (-0d).##)
    but this is more obviously correct.
A little cleanup along the Any to AnyRef trail.

Followup to 35316be and d3f879a.

 - Remove obsolete comments and replace them with a test.
 - Don't emit error addendum unless we know we're dealing
   with a value class.
Fix for SI-6340, error message regression.
SI-6306 Remove incorrect eta-expansion optimization in Uncurry

Fix SI-6306 by removing the offending code. Moreover, clarify comment
and add testcase.

This pattern match only matches on testcases triggering SI-6306; the
transformation it performs in that case is unsafe.

The intended optimization is to undo eta-expansion of nullary functions,
that is, transform `() => foo()` to `foo`. But that's only valid when
`foo` is an instance of `Function0`, so the optimization is unsafe.
Moreover, the pattern match will fail because at the end of typer that
code has become `() => foo.apply()`, and `isExprSafeToInline(foo.apply)`
always (correctly) fails the isExprSafeToInline test. The pattern match
should thus be different - this code was dead even when it was
introduced (45bcd02f6ba099277bedbf83ec2bda07435c7797), since it was not
invoked either when building the compiler or when compiling function
attempt2() in the included testcase.

Thanks to all commenters on SI-6306 and
https://github.com/scala/scala/pull/1255, in particular to Jason Zaugg
for diagnosing the underlying fault and Lukas Rytz for understanding the
goal of the code.
magic classes are no longer entered twice

Previously magic classes such as NothingClass were entered twice
into root mirrors of java universes. No idea how this managed not to blow up.
Now this problem is fixed.

Also, as usual when I gain understanding of something, this allows to come up
with better names. `magicSymbols` are now split into three collections:
`magicallyEnteredClasses`, `magicallyEnteredMethods` and `magicallyHijackedSymbols`.
Fix for SI-6367, exponential time in inference.

This pathology is not new - it can be witnessed in 2.9,
where compiling the test case enclosed with this ticket with
-Yinfer-debug will print a line with (pinky to lips) one million
type parameters. 1048576 actually, aka 2^20. But in 2.9 we were
somehow getting away with creating the list, presumably by not
spending much time looking at it. Somewhere between there and M1,
that changed.

I cut it off at the knees - don't create a list of one million
upper bound constraints when 1 will suffice. It would not be too
surprising if this proves to be a boon for performance.
Merge pull request #1255 from Blaisorblade/issue/6306

Fix SI-6306 on testcase
Test case for a bug fixed in M7.
Pending test for SI-3943
Rescued TreeBuilder from the parser.

For too long, Tree Builder has ruled over those who would
like to build their own trees.  Today marks the start of a
new era.  Trees are for building, not for parsers to hoard.
It's in Global now.

The particular motivation is exposing makeNew, and I also
added makeAnonymousNew, so rather than this...

Apply(Select(
  Block(List(ClassDef(
    Modifiers(scala.tools.nsc.symtab.Flags.FINAL), tpnme.ANON_CLASS_NAME, Nil,
    Template(List(Ident(definitions.AnyRefClass)), emptyValDef, List(
      DefDef(NoMods, nme.CONSTRUCTOR, Nil, List(Nil), TypeTree(), Block(
        List(Apply(Select(Super(This(tpnme.EMPTY), tpnme.EMPTY), nme.CONSTRUCTOR), Nil)),
        Literal(Constant(()))
      )))))),
  Apply(Select(New(Ident(tpnme.ANON_CLASS_NAME)), nme.CONSTRUCTOR), Nil))
, sn.GetClass), Nil)

We can write this.

  Apply(Select(makeAnonymousNew(Nil), nme.getClass_), Nil)
Better error message for pattern arity errors.

Because friends don't tell friends:

  "wrong number of arguments for <none>"
Merge pull request #1296 from paulp/210-errors-and-trees

210 errors and trees
Merge pull request #1294 from paulp/issue/6367

Fix for SI-6367, exponential time in inference.