SI-7312 @deprecatedInheritance now ignores same-file subclasses

This allows us to deprecate external inheritances as a prelude
to sealing a class, without enduring the warnings ourselved in
interlude.
SI-7315 Test @deprecatedInheritance / @specialized interplay

Don't warn about the specialized subclass.

Fixed in the previous commit for a similar issue SI-7312.
SI-6937 core type tags are no longer referentially unique

Type tag factory used to evaluate the provided type creator in the
context of the initial mirror in order to maintain referential equality
of instances of standard tags. Unfortunately this evaluation might fail
if the mirror provided doesn't contain the classes being referred to.
Therefore I think we should avoid evaluating type creators there.

Note that failure of evaluation doesn't mean that there's something
bad going on. When one creates a type tag, the correct mirror /
classloader to interpret that tag in might be unknown (like it happens
here). This is okay, and this is exactly what the 2.10.0-M4 refactoring
has addressed.

Something like `res2.typeTag[A].in(currentMirror)` should be okay.
SI-7337 Error out on missing -d directory.

This check was removed without comment in 3a30af154, the addition
of JSR-223 support for the interpreter.

After this commit, I manually tested that JSR-223 support works.

    scala> import javax.script._, collection.JavaConverters._; val manager = new ScriptEngineManager; manager.getEngineByName("scala").eval("List(1)")
    import javax.script._
    import collection.JavaConverters._
    manager: javax.script.ScriptEngineManager = javax.script.ScriptEngineManager@4418f61b
    res1: Object = List(1)

3a30af154 did not include a test case, so I don't know whether I've
broken some other aspect of it. I tried the above as a `run` test,
but hit two problems, one of them seemingly our fault, and the other
a MacOS JDK wrinkle.

  1. scala.reflect.internal.MissingRequirementError: object scala.runtime in compiler mirror not found.
  2. java.lang.UnsatisfiedLinkError: no AppleScriptEngine in java.library.path

I can't find my way to fix these, so JSR-223 remains untested. I don't
think that commit was really up to standard; it could handle additional
review, documentation, and testing. It might even be modularized so as
not to pollute the REPL itself.
SI-7329 duplicate default getters for specialized parameters.

The default getter is generated with @specialized annotation if the
type parameter corresponding to the type of the parameter is
specialized. Consequently specialize pass tries to generate overloads.

Rather than pruning overloads to exclude duplicates, let's notice
that default getter specialization is not needed at all:
  - The dynamic scope of default getter doesn't include specialized
    method or class constructor.
  - generic default getter is called even when calling specialized
    method:
    object V {
      @specialized def foo[@specialized B](b: B = (??? : B)) = {}
      foo[Int]()
    }
    gives:
      invokevirtual Method V$.foo$default$1:()Ljava/lang/Object;
      invokestatic (unboxToInt)
      invokevirtual Method V$.foo$mIc$sp:(I)V
Revert "SI-6387 Clones accessor before name expansion"

This reverts commit 4e10b2c833fa846c68b81e94a08d867e7de656aa.

Add 6387 test to pending and 7341 to up-to-date.
SI-7335 Mandate that parents of Predef must be defined in Predef.scala

This avoids thorny issues of cyclic references and/or missing symbol errors
due to the way Predef is completed earlier than user classes, and due to the
addition of `import Predef._` to LowPriorityImplicits.scala. More details in
Lukas's comments in [2].

How did we bootstrap originally? Manually ordering source files,
either in the Ant Build [1], or later in Global [2]. But neither mechanism
remains in place (due, I suppose, to the difficulty in defending them
with a test case.) The reordering in Global was removed in [3].

After the change, we can compile the standard library without the
results of a prior compilation run on the classpath.

    rm -rf target/locker/library/classes/scala && export LIB=build/pack/lib; java -Xmx1G -cp $LIB/scala-library.jar:$LIB/scala-reflect.jar:$LIB/scala-compiler.jar:$LIB/forkjoin.jar scala.tools.nsc.Main @args.txt
    src/library/scala/SerialVersionUID.scala:15: warning: Implementation restriction: subclassing Classfile does not
    make your annotation visible at runtime.  If that is what
    you want, you must write the annotation class in Java.
    class SerialVersionUID(value: Long) extends scala.annotation.ClassfileAnnotation
          ^
    warning: there were 75 deprecation warning(s); re-run with -deprecation for details
    warning: there were 1 unchecked warning(s); re-run with -unchecked for details
    warning: there were 5 feature warning(s); re-run with -feature for details
    four warnings found

 Where @args.txt contains:

     -classpath
     lib/forkjoin.jar:target/locker/library/classes
     -sourcepath
     src/library
     -d
     target/locker/library/classes
     src/library/scala/Function3.scala
     src/library/scala/Console.scala
     <more of src/library/**, unsorted>

This change will break scala-virtualized, which will need to move
the contents of StandardEmbeddings.scala into Predef.scala.

[1] https://github.com/scala/scala/commit/c5441dc
[2] https://github.com/scala/scala/commit/e72f0c7
[3] https://github.com/scala/scala/pull/968
SI-7335 Don't import Predef._ in Predef.scala

The check for this was foiled by the introduction of
DeprecatedPredef in c26a8db0. This didn't cause any
harm, but in any case this commit restores the intended
state of affairs.

The change is visible only through logging; no test case
is included.

    qbin/scalac -Ydebug -Ylog:all src/library/scala/Predef.scala -Ystop-after:typer 2>&1 | grep -i "Omitted import of Predef"
    [log namer] Omitted import of Predef._ for Predef.scala
    [log typer] Omitted import of Predef._ for Predef.scala

A redundant override of `firstDefinesClassOrObject` is also
removed.

Maybe we can remove the special case altogether?
SI-7335 Add logging for a now-impossible* case in Symbol#exists.

* Impossible (to the best of my knowledge) because LowPriorityImplicits
is now defined in Predef.scala. Were I more sure, we could trip an
assertion here, rather than the devWarning.
SI-7335 Sharpen up comment about implicit prioritization.
SI-7289 Less strict type application for TypeVar.

When a type constructor variable is applied to the wrong number of arguments,
return a new type variable whose instance is `ErrorType`.

Dissection of the reported test case by @retronym:

Define the first implicit:

    scala> trait Schtroumpf[T]
    defined trait Schtroumpf

    scala> implicit def schtroumpf[T, U <: Coll[T], Coll[X] <: Traversable[X]]
         |     (implicit minorSchtroumpf: Schtroumpf[T]): Schtroumpf[U] = ???
    schtroumpf: [T, U <: Coll[T], Coll[X] <: Traversable[X]](implicit minorSchtroumpf: Schtroumpf[T])Schtroumpf[U]

Call it explicitly => kind error during type inference reported.

    scala> schtroumpf(null): Schtroumpf[Int]
    <console>:10: error: inferred kinds of the type arguments (Nothing,Int,Int) do not conform to the expected kinds of the type parameters (type T,type U,type Coll).
    Int's type parameters do not match type Coll's expected parameters:
    class Int has no type parameters, but type Coll has one
                  schtroumpf(null): Schtroumpf[Int]
                  ^
    <console>:10: error: type mismatch;
     found   : Schtroumpf[U]
     required: Schtroumpf[Int]
                  schtroumpf(null): Schtroumpf[Int]
                            ^

Add another implicit, and let implicit search weigh them up.

    scala> implicitly[Schtroumpf[Int]]
    <console>:10: error: diverging implicit expansion for type Schtroumpf[Int]
    starting with method schtroumpf
                  implicitly[Schtroumpf[Int]]
                            ^

    scala> implicit val qoo = new Schtroumpf[Int]{}
    qoo: Schtroumpf[Int] = $anon$1@c1b9b03

    scala> implicitly[Schtroumpf[Int]]
    <crash>

Implicit search compares the two in-scope implicits in `isStrictlyMoreSpecific`,
which constructs an existential type:

   type ET = Schtroumpf[U] forSome { type T; type U <: Coll[T]; type Coll[_] <: Traversable[_] }

A subsequent subtype check `ET <:< Schtroumpf[Int]` gets to `withTypeVars`, which
replaces the quantified types with type variables, checks conformance of that
substitued underlying type against `Schtroumpf[Int]`, and then tries to solve
the collected type constraints. The type var trace looks like:

    [    create] ?T                       ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] )
    [    create] ?U                       ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] )
    [    create] ?Coll                    ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] )
    [   setInst] Nothing                  ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], T=Nothing )
    [   setInst] scala.collection.immutable.Nil.type( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], U=scala.collection.immutable.Nil.type )
    [   setInst] =?scala.collection.immutable.Nil.type( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], Coll==?scala.collection.immutable.Nil.type )
    [    create] ?T                       ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] )
    [   setInst] Int                      ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], T=Int )
    [    create] ?T                       ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] )
    [    create] ?U                       ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] )
    [    create] ?Coll                    ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]] )
    [   setInst] Nothing                  ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], T=Nothing )
    [   setInst] Int                      ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], U=Int )
    [   setInst] =?Int                    ( In Test#schtroumpf[T,U <: Coll[T],Coll[_] <: Traversable[_]], Coll==?Int )

The problematic part is when `?Int` (the type var originated from `U`) is registered
as a lower bound for `Coll`. That happens in `solveOne`:

    for (tparam2 <- tparams)
      tparam2.info.bounds.hi.dealias match {
        case TypeRef(_, `tparam`, _) =>
          log(s"$tvar addLoBound $tparam2.tpeHK.instantiateTypeParams($tparams, $tvars)")
          tvar addLoBound tparam2.tpeHK.instantiateTypeParams(tparams, tvars)
        case _ =>
      }
SI-6386 typed existential type tree's original now have tpe set

Tree reification fails for ExistentialTypeTree. The reason is that the
tree passed for reification (see reifyTree at GetTrees.scala) must have
not null tpe (see reifyBoundType at GenTrees.scala), which is not true
in the case of ExistentialTypeTree.

Why is it so? The tree passed to reifyTree was obtained in the reshape
phase of reificationusing using original TypeTrees that reporesent pre-
typer representation of a type. The problem is that original's tpe for
ExistentialTypeTree is not set.

So the solution to the issue is to create ExistentialTypeTree's original
in a such way that is has actual tpe set.
Merge pull request #2349 from scalamacros/ticket/6937

SI-6937 core type tags are no longer referentially unique
Merge pull request #2354 from adriaanm/ticket-7289

SI-7289 Less strict type application for TypeVar.
Merge pull request #2365 from u-abramchuk/SI6386

SI-6386 typed existential type tree's original now have tpe set
Merge pull request #2367 from vigdorchik/si-6387-revert

Revert "SI-6387 Clones accessor before name expansion"
Reifier -> AST Node test.

It's a Node-by-Node tour of the reifier's abilities and
occasional foibles.

That is one spectacularly attractive checkfile.
SI-6286 IllegalArgumentException handling specialized method.

Specialize assigns SpecialOverride info to a specialized method
even when there is a further specialization that should be forwarded
to.
Remove scaladoc deprecated option.

Remove -external-urls that had been previously deprecated in 2.10.
SI-7360 Don't let a follow-up TypeError obscure the original error.

When supplementing a fatal error message with context (current
compilation unit, tree, phase, etcetera), we must be cautious to
not to trigger another error which will obscure the original one.

Currently, `supplementErrorMessage` does its working a try catch
that only catches `Exception`. But this fails to catch
CyclicReferenceError (<: TypeError <: Throwable), as was seen
in a recent mailing list post by Greg Meredith.

This commit extends the catch clause.