SI-7296 Avoid crash with nested 23-param case class

The implementation restriction doesn't stop subsequent
typechecking in the same compilation unit from triggering
type completion which tries to synthesize the unapply
method.

This commit predicates generation of the unapply method
on having 22 or fewer parameters.
SI-7296 Remove arity limit for case classes

When venturing above the pre-ordained limit of twenty
two, `Companion extends FunctionN` and `Companion.unapply`
are sacrificed. But oh-so-many other case class features
work perfectly: equality/hashing/stringification, the apply
method, and even pattern matching (which already bypasses
unapply.)

There was some understandable fear of the piecemeal when
I tabled this idea on scala-internals [1]. But I'd like
to persist as this limit is a needless source of pain for
anyone using case classes to bind to database, XML or JSON
schemata.

[1] https://groups.google.com/forum/#!topic/scala-internals/RRu5bppi16Y
An IntelliJ Module for the recently modularized REPL.
Overhauled local/getter/setter name logic.

Sifted through extraneous methods trying to find consistency,
consolidating and deprecating as I went. The original motivation
for all this was the restoration of LOCAL_SUFFIX to originalName,
because:

  It looks like in an attempt to make originalName print
  consistently with decodedName, I went a little too far and
  stripped invisible trailing spaces from originalName. This
  meant outer fields would have an originalName of '$outer'
  instead of '$outer ', which in turn could have caused them to
  be mis-recognized as outer accessors, because the logic of
  outerSource hinges upon "originalName == nme.OUTER".

  I don't know if this affected anything - I noticed it by
  inspection, improbably enough.

Deprecated originalName - original, compared to what? - in
favor of unexpandedName, which has a more obvious complement.

Introduced string_== for the many spots where people have
given up and are comparing string representations of names.
A light dusting of types is still better than nothing.

Editoral note: LOCAL_SUFFIX is the worst. Significant trailing
whitespace! It's a time bomb.
SI-7232 Fix Java import vs defn. binding precendence

Java Spec:
> A single-type-import declaration d in a compilation unit c
> of package p that imports a type named n shadows, throughout
> c, the declarations of:
>   - any top level type named n declared in another compilation
>     unit of p
>   - any type named n imported by a type-import-on-demand
>     declaration in c
>   - any type named n imported by a static-import-on-demand
>     declaration in c

Scala Spec:
> Bindings of different kinds have a precedence deﬁned on them:
>   1. Deﬁnitions and declarations that are local, inherited, or made
>      available by a package clause in the same compilation unit where
>      the deﬁnition occurs have highest precedence.
>   2. Explicit imports have next highest precedence.

This is a forward port of 6e79370, which did not merge cleanly
and was omitted in the regular merge from 2.10.x to master.

Conflicts:
	src/compiler/scala/tools/nsc/typechecker/Typers.scala
SI-7259 Fix detection of Java defined Selects

The fix for SI-3120, 3ff7743, introduced a fallback within
`typedSelect` that accounted for the ambiguity of a Java
selection syntax. Does `A.B` refer to a member of the type `A`
or of the companion object `A`? (The companion object here is a
fiction used by scalac to group the static members of a Java
class.)

The fallback in `typedSelect` was predicated on
`context.owner.enclosingTopLevelClass.isJavaDefined`.
However, this was incorrectly including Select-s in top-level
annotations in Scala files, which are owned by the enclosing
package class, which is considered to be Java defined. This
led to nonsensical error messages ("type scala not found.")

Instead, this commit checks the compilation unit of the context,
which is more direct and correct. (As I learned recently,
`currentUnit.isJavaDefined` would *not* be correct, as a lazy type
might complete a Java signature while compiling some other compilation
unit!)

A bonus post factum test case is included for SI-3120.

Manual forward port of f046853 which was not merged as
part of the routine 2.10.x to master merge. The test case
uncovered a NullPointerExceptiion crasher in annotation
typechecking introduced in 5878099c; this has been prevented
with a null check.

Conflicts:
	src/compiler/scala/tools/nsc/typechecker/Typers.scala
Improve testing interactive experience.

Currently the exceptions that happen in the test are swallowed, as
the JVM is forced to exit before printing the stack trace.
Also assert message doesn't contain information about the problem.

The call to "sys.exit" masks bugs in the testing framework, that
has to be addressed more elaborately, so here we remove it. Also
add the message parameter to assert to make it more informative.

After removing "sys.exit" call, doc test starts failing. I suspect
there might be a problem when expanding doc variables, but this
should be addressed separately.
Iterator.++ no longer blows the stack.

To my chagrin we still hadn't gotten this one. I took a new
approach which seems like a winner to me. Here's a benchmark:

object Test {
  def run(n: Int) = println((1 to n).foldLeft(Iterator.empty: Iterator[Int])((res, _) => res ++ Iterator(1)) sum)
  def main(args: Array[String]): Unit = run(args(0).toInt)
}

Runtime before this commit for various n:

  500   0.403 real
  1000  0.911 real
  1500  2.351 real
  2000  5.298 real
  2500 10.184 real

Runtime after this commit, same n:

  500  0.346 real
  1000 0.359 real
  1500 0.368 real
  2000 0.379 real
  2500 0.390 real

In the test case I dial it up to 100000.
Merge pull request #2311 from retronym/topic/repl-intellij

An IntelliJ Module for the recently modularized REPL.
Merge pull request #2289 from paulp/pr/name-logic

Name logic consistency
SI-7186 Slim down some TypeRefs by 8 bytes.

By virtue of being defined in object TypeRef, they
had two outer pointers.

    $outer  scala.reflect.internal.Types$TypeRef$
    $outer  scala.tools.nsc.Global

This commit moves them out of that object. They also
now are no longer shrouded in anonymity, which is
pleasant when debugging and profiling.

The shallow size leaderboard now looks like:

   Class             % Shallow  % Objects
                          Size
-----------------------------------------
1. ::                      14%        25%
2. char[]                  10% a       5%
3. ClassArgsTypeRef         6%         5%
4. Object[]                 6% b       1%
5. TypeHistory              5%         6%
6. AbstractTypeSymbol       4%         2%
7. AbsractNoArgsTypeRef     3%         2%
8. j.l.Class                3%         2%
9. TermSymbol               2%         1%
10. HashEntry               1% c       1%

a) 6% of the char[] by size is the name table.
   Retained source code seems to be sizable => should we discard after parsing?
b) Types.uniques
c) ZipArchive#DirEntry.entries

Confirmation of the slimmer size can be seen in:

  https://github.com/retronym/scala/compare/ticket/7186

In that branch, I introduced infrastructure to query JVM
object size in instrumented tests, and the diff shows:

       size                class instance
 ========================================================================
-  64 bytes  internal.Types$TypeRef$$anon$5 List[Int]
-  64 bytes  internal.Types$TypeRef$$anon$6 String
+  56 bytes  nternal.Types$ClassArgsTypeRef List[Int]
+  56 bytes  ernal.Types$ClassNoArgsTypeRef String

I chose not to bring that test infrastructure across to master so as
not to burden us with brittle tests built on esoteric facilities.

This does not close the ticket which proposes a different
space optimization which is also explored in that branch,
but no a clear cut improvement.
Merge pull request #2325 from retronym/ticket/7186-2

SI-7186 Slim down some TypeRefs by 8 bytes.
SI-7302 importing from Any.

Turns out the "minor tweaks" in 632daed4ed were only minor
for major values of minor. You can indeed import members from
Any/Object, so long as you rename them. Reverted logic error.
Test case will accompany SI-7233 upon merge into master.
Merge pull request #2323 from paulp/pr/iterator_++

Iterator.++ no longer blows the stack.
Merge commit 'refs/pull/2326/head' into pr/merge-395e90a786
Merge commit '395e90a786' into pr/merge-395e90a786

* commit '395e90a786':
  SI-7251, compiler crash with $.
  SI-7240 fixes language feature lookup
  SI-7233 Account for aliased imports in Erasure
  SI-7233 Account for aliased imports in eta expansion.
  SI-7132 - don't discard Unit type in interpreter
  SI-6725 `f` interpolator now supports %n tokens

Conflicts:
	src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
	src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
	src/repl/scala/tools/nsc/interpreter/ExprTyper.scala
Merge pull request #2333 from paulp/pr/merge-395e90a786

Merge 2.10.x (through 395e90a786) into master.
Merge pull request #2316 from vigdorchik/interactive_test_framework

Improve testing interactive experience.
Merge pull request #2305 from retronym/ticket/7296-2

SI-7296 Lifting the limit on case class arity
Merge pull request #2318 from retronym/ticket/7259-master

[forward port] SI-7259 Fix detection of Java defined Selects