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-6123: -explaintypes should not explain errors which won't be reported

-explainTypes means that only type tests which *fail* should be reported in more
detail by using explainTypes. Hence, callers of explainTypes should check if
type errors are being ignored, by checking context.reportErrors. Hence, this
check is added to Inferencer, and another call site is redirected to that
method.

Moreover, explainTypes should only be called if an error exists. Enforce that in
checkSubType, and remove spurious home-made explainTypes output.

Finally, in ContextErrors, stop checking `settings.explaintypes.value` before
calling `explainTypes` which will check it again.

Note that this patch does not fix all occurrences, but only the ones which
showed up during debugging. The other ones never cause problems, maybe because
they occur when contextErrors is in fact guaranteed to be true. We might want to
fix those ones anyway.

This fixes regressions in c800d1fec5241ed8c29e5af30465856f9b583246 and
78f9ef3906c78413ff8835fdad3849bfe5516be2.

Thanks to hubertp (Hubert Plociniczak) for the first round of review.

Refs #6123
backport to _2.10.x_
Add positive and negative testcases for SI-6123 (-explaintypes)

Positive testcases compile reduced known offenders to verify that no output is
produced.

The negative testcase tests that -explaintypes actually produces output on code which fails
to compile. I have altered an existing testcase, `test/files/neg/abstract`,
adding -explaintypes to the flags.

This testcase is currently mostly ineffective, as partest currently ignores the
standard output (SI-7003). It will become more effective when SI-7003 is fixed.
But already now, testers would at least be able to notice extraneous output.

This argument is somewhat bogus, but this patch is no worse than the other ones
which are committed while SI-7003 is open.
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.
Doc -> C-style comments for local symbols to avoid "discarding
unmoored doc comment" warning when building distribution for
scala itself.
SI-7102 Specialize isEmpty for bitsets

Currently bitsets use default isEmpty implementation inherited from
Set, which tests for "size == 0".

Calculating the size of a word in a bitmap requires summing through
all bits set, whereas testing for emptyness needs only one comparison
with zero.

This commit overrides the default implementation with the specialized
one looking for a non-zero word in this bitmap.
Merge pull request #2287 from vigdorchik/ticket/si-7102

SI-7102 Override isEmpty for bitsets with an efficient implementation
Bypass determination of protection domain when resource is not in a jar
The script engine is given a better binding mechanism and reflexive access

Better binding mecanism : formerly done through the default SimpleBindings
shipped with the API, it now goes through a custom IBindings class
which uses the bind method of the interpreter instead of simply
making the bindings available as a Map.

Reflexive access : the script engine is made available to itself
through a bound variable "engine" of type javax.script.ScriptEngine.
This will allow "variable injection" i.e. programmatic redefinition
of variables, among others.
Merge pull request #2259 from Blaisorblade/issue/6123-try-3

SI-6123: -explaintypes should not explain errors which won't be reported, new attempt
SI-5717 error when bytecode cannot be written

If there's an existing file foo when emitting a class file for foo.Bar,
then emit an error at foo.Bar, similar to what javac does.

The error message looks something like:

foo.scala:4: error: error writing object Foo: ./mypkg/Foo.class: ./mypkg is not a directory
Sanity for build.xml: exscriptus&positus delendus est.

Reduced copy/pasting to the best of my antabilities.
The next person to duplicate anything without written
permission will be sentenced to a week in xmhell.

While I was at it, made sure that layering is respected.
The quick phase exclusively uses the locker compiler for building.

The jar task will fail when trying to create an empty jar.

Replaced the crazy if/unless/depends constructs by if/then/else.
Version suffix computation should now be comprehensible.
I threw in some validation to make sure the various suffixes are consistent.

Also, no more init/pre-foo tasks unless absolutely necessary.

Introduced a couple of macros to capture the essence of staged compilation.

Notes:
  - remove lib.extra, standardize on aux.libs
  - collapse *.javac.path and *.build.path
  - rename starr.classpath to starr.compiler.path
  - only repl needs jline, locker.compiler.path = locker.comp.build.path + forkjoin
  - more uniform build.paths (compiler = reflect + library)
    - uniformity means slightly bigger classpaths
      (e.g. forkjoin is only used in library,  but inherited by compiler)
    - pruned: some spurious dependencies removed
    - compilerpathref = compiler build path
  - silence test.osgi, by hook or by crook
  - centralized clean tasks
  - reduce duplication in property usage
  - fix pack.xml to pack scaladoc/partest instead of scaladoc/scala-partest
  - TODO: -XDignore.symbol.file necessary for library? only needed for forkjoin?
  - document usage from jenkins, fix typo: partest.scalac*_*opts

New targets:
 - quick-opt
 - strap-opt
 - test.bc
 - test.osgi
 - test.osgi.comp
 - test.osgi.init
 - test.stability-opt

Removed/replaced targets:
 - asm.clean asm.lib asm.start
 - bc.run
 - dist.latest dist.latest.unix dist.latest.win dist.start
 - docs.all docs.manmaker docs.pre-comp docs.pre-continuations-plugin
 - docs.pre-jline docs.pre-lib docs.pre-man docs.pre-partest docs.pre-scalap
 - forkjoin.clean forkjoin.lib forkjoin.pack forkjoin.start
 - graph.clean
 - init.build.nopatch.release init.build.patch.release init.build.release
 - init.build.snapshot init.build.suffix.done init.extra.tasks
 - init.fail.bad.jdk init.hasbuildnum init.hasmavensuffix init.jars
 - init.jars.check init.maven.jars init.maven.tasks init.osgi.suffix
 - init.osgi.suffix.final init.osgi.suffix.snapshot init.testjava6
 - init.version.done init.version.git init.version.release init.version.snapshot
 - init.warn.jdk7 locker.pre-comp locker.pre-lib locker.pre-reflect
 - locker.unlock.comp locker.unlock.lib locker.unlock.pre-comp
 - locker.unlock.pre-lib locker.unlock.pre-reflect locker.unlock.reflect
 - osgi.clean osgi.test osgi.test.comp osgi.test.init
 - pack.clean pack.pre-bin pack.pre-comp pack.pre-lib pack.pre-partest
 - pack.pre-plugins pack.pre-reflect pack.pre-scalap pack.start
 - palo.comp palo.lib palo.pre-bin palo.pre-comp palo.pre-lib palo.pre-reflect
 - palo.reflect palo.start quick.pre-bin
 - quick.pre-comp quick.pre-interactive quick.pre-lib quick.pre-partest
 - quick.pre-plugins quick.pre-reflect quick.pre-repl quick.pre-scalacheck
 - quick.pre-scaladoc quick.pre-scalap
 - sbt.clean sbt.compile sbt.done sbt.libs sbt.start
 - starr.clean
 - strap.clean strap.pre-comp strap.pre-lib strap.pre-reflect strap.start
 - test.debug test.pre-run