SI-7242 Fix crash when inner object mixes in its companion

Given:

    class C {
      trait T { C.this }            // C$T$$$outer$ : C
      object T extends T { C.this } // C$T$$$outer$ : C.this.type
    }

object T ended up with a definitions for both of the accessors.
These cannot co-exist, as they have the same erased type. A crash
ensued almost immediately in explitouter.

Fortunately, the solution is straightforward: we can just omit
the mixin outer accessor altogether, the objects own outer accessor
is compatible with it.

    scala> :javap C.T
    Compiled from "<console>"
    public interface C$T{
        public abstract C C$T$$$outer();
    }

    scala> :javap C.T$
    Compiled from "<console>"
    public class C$T$ extends java.lang.Object implements C$T{
        public C C$T$$$outer();
        public C$T$(C);
    }

I also added an assertion to give a better error message in
case we find ourselves here again.

Also includes tests from SI-3994, which I'll mark as a duplicate.
SI-7258 Don't assume order of reflection values in t6223

test/files/run/t6223's check file expects a specific
ordering of the reflected values. The ordering is not
guaranteed by the runtime/reflection API and can change.

Therefore, sort the values before comparing them.
SI-7253: respect binary compatibility constraints

From the JLS one can prove that moving a method to a superclass is a binary
compatible change, both forward and backward. That's because when compiling a
method call `c.foo()`, where c: C, the output descriptor *must* refer to `C` and
not to the class where `foo()` is actually defined.

This patch just ensures that, and adds a test comparing generated descriptors
against the Javac output.

The sample code is from Paul Philipps, the fix and the bytecode comparison code
from me.

From 2006 (9954eafffd5e60676238369ab0ed5797c92b4a7b, a fix for bug 455 in the
old bug tracker
http://www.scala-lang.org/sites/default/files/aladdin/displayItem.do%3Fid=455.html)
until 2.9, Scalac has followed this rule "often" (that is, when C is *not* an
interface).

This behavior was wrong, but the bug was hard to trigger. AFAICS, this can
create problems only when moving a method to a super interface in a library and
expecting forward binary compatibility - that is, compiling some Scala client
code against the new version of the library, and trying to run this code against
the old version of the library. This change grows an interface, so it is valid
only if clients are supposed to *not* implement the library.  Apparently, this
is so rare that nobody noticed.

Since 2.10 (0bea2ab5f6b211a83bbf14ea46fe57b8163c6334), Scalac follows this rule
*only* when C is an interface (I assume by oversight, since the main change was
an accessibility check), so the bug was finally triggered.

The new code will have to emit INVOKEINTERFACE instead of INVOKEVIRTUAL a bit
more often, compared to 2.9 (but not to 2.10). I don't know whether
INVOKEINTERFACE is noticeably slower (it shouldn't be); but this is the safest
fix since this behavior is mandated by the JLS.
If somebody disagrees and believes the 2.9 is significantly faster, IMHO he
should send a separate pull request (although ProGuard is probably a better
place for the change).
Remove fragile code, made redundant by previous commit

The JLS requires, as an exception to generate calls referring to Object for all
methods defined in Object itself; hence, whenever the method owner is Object,
the call should refer to the method owner. The previous commit implemented this
directly in useMethodOwner, so the special case for Object in isInterfaceCall is
now redudant. Hence, remove it.
SI-7253: update comments and naming

Rename isInterfaceCall -> needsInterfaceCall, which is more accurate since a
receiver can't literally be an interface call.
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-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.
Reduce duplication and increase verbosity in MiMa execution.

This helps to see whether we've broken forward or backward
binary compatibility.
removes duplication in FreeDef extractors
an amazing discovery made by Iulian

Traces were stalling macro expansions by evaluating messages even when
-Ymacro-debug-* flags were disabled.
Merge pull request #2271 from retronym/topic/mima-refactor

Reduce duplication and increase verbosity in MiMa execution.
SI-5699 correct java parser for annotation defs.

Correct java source parser not to insert a constructor with the type
 of its value method.
fixes the craziness in JavaUniverse.log

This long-standing, but trivial to fix nuisance in the implementation of
runtime reflection actively avoided being fixed in both 2.10.0 and 2.10.1.

It's finally the time to put it to a rest.
Merge pull request #2269 from retronym/ticket/7259

SI-7259 Fix detection of Java defined Selects
Merge pull request #2261 from soc/SI-7258

SI-7258 Don't assume order of reflection values in t6223
Merge pull request #2283 from scalamacros/topic/silence-the-log

fixes the craziness in JavaUniverse.log
Merge pull request #2276 from scalamacros/topic/macro-trace

an amazing discovery made by Iulian
Merge pull request #2245 from retronym/ticket/7242

SI-7242 Fix crash when inner object mixes in its companion
Merge pull request #2268 from scalamacros/topic/shannon-entropy

removes duplication in FreeDef extractors
Merge pull request #2274 from vigdorchik/ticket/si-5699

SI-5699 correct java parser for annotation defs.