SI-6725 `f` interpolator now supports %n tokens

Currently the `f` interpolator supports format specifiers which
specify conversions for formatted arguments. However Java formatting
is not limited to argument-related conversions as explained in:
http://docs.oracle.com/javase/6/docs/api/java/util/Formatter.html#detail.

Conversions which don't correspond to any arguments are `%` (used to
emit verbatim `'%'` characters) and `n` (used to emit platform-specific
line separators). Of those only the former is supported, and this patch
fixes the oversight.
SI-7132 - don't discard Unit type in interpreter
SI-7233 Account for aliased imports in eta expansion.

Buggy:

    treeCopy.Select(sel, sel.qual, sel.name) setSymbol null
    Select(sel, sel.qual, sel.name)

Okay:

    treeCopy.Select(sel, sel.qual, sel.name)
    Select(sel, sel.qual, sel.symbol.name) // but doesn't copyAttrs!

It is an easy mistake to make, I've found one more occurance:

  def foo(a: Any) = { import a.{toString => toS}; toS }

    error: uncaught exception during compilation: scala.reflect.internal.FatalError
    scala.reflect.internal.FatalError: class Object does not have a member toS
        at scala.reflect.internal.Definitions$DefinitionsClass.scala$reflect$internal$Definitions$DefinitionsClass$$fatalMissingSymbol(Definitions.scala:1028)

A followup commit will address that problem.
SI-7233 Account for aliased imports in Erasure

When we discard the fiction of `scala.Any`.
SI-7240 fixes language feature lookup

As I discovered today, Definitions.getMember have a fallback clause,
which accounts for the phases which have inner classes flattened.

This fallback uses nme.flattenedName to compute a flattened name, but
unfortunately nme.flattenedName produces a TermName, not a TypeName,
which means that the fallback will commence search in a wrong namespace
with predictable results.

The commit also changes another usage of nme.flattenedName in a type name
context. That one was correctly converting a TermName result to TypeName,
so this is not a bugfix, but just a refactoring for the sake of being
consistent.
Merge pull request #2227 from mergeconflict/2.10.x-SI-7132

SI-7132 - don't discard Unit type in interpreter
Merge pull request #2222 from scalamacros/ticket/6725

SI-6725 `f` interpolator now supports %n tokens
Merge pull request #2230 from retronym/ticket/7233

SI-7233 Account for aliased imports in EtaExpansion / Erasure
Merge pull request #2234 from scalamacros/ticket/7240

SI-7240 fixes language feature lookup
SI-7251, compiler crash with $.

We don't need to assert our way out of tight spots, we can issue
an error. Or so I once thought.

It turns out lots of assertions have been disappearing before
being heard thanks to "case t: Throwable". Under such conditions,
a failed assertion is a no-op, but an error is an error.

The crash associated with SI-7251 is best avoided by removing the
assertion, which allows an error to be issued in the normal course
of events.

In the course of trying to figure out the above, I cleaned up
ClassfileParser somewhat.
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