Make value classes TreeCheckers friendly

 - allow for re-typechecking by disabling "redefinition of
   equals" errors for synthetic methods.
Ill-scoped reference checking in TreeCheckers

Find trees which have an info referring to an out-of-scope
type parameter or local symbol, as could happen in the test
for SI-6981, in which tree transplanting did not substitute
symbols in symbol infos.

The enclosed, pending test for that bug that will now
fail under -Ycheck:extmethods -Xfatal-warnings.

    [Now checking: extmethods]
    [check: extmethods] The symbol, tpe or info of tree `(@scala.annotation.tailrec def loop(x: A): Unit = loop(x)) : (x: A)Unit` refers to a out-of-scope symbol, type A in class Foo. tree.symbol.ownerChain: method loop, method bippy$extension, object Foo, object O, package <empty>, package <root>
    [check: extmethods] The symbol, tpe or info of tree `(val x: A = _) : A` refers to a out-of-scope symbol, type A in class Foo. tree.symbol.ownerChain: value x, method loop, method bippy$extension, object Foo, object O, package <empty>, package <root>
    [check: extmethods] The symbol, tpe or info of tree `(loop(x)) : (x: A)Unit` refers to a out-of-scope symbol, type A in class Foo. tree.symbol.ownerChain: method loop, method bippy$extension, object Foo, object O, package <empty>, package <root>
    [check: extmethods] The symbol, tpe or info of tree `(loop) : (x: A)Unit` refers to a out-of-scope symbol, type A in class Foo. tree.symbol.ownerChain: method loop, method bippy$extension, object Foo, object O, package <empty>, package <root>
    [check: extmethods] The symbol, tpe or info of tree `(x) : A` refers to a out-of-scope symbol, type A in class Foo. tree.symbol.ownerChain: value x, method loop, method bippy$extension, object Foo, object O, package <empty>, package <root>
    [check: extmethods] The symbol, tpe or info of tree `(<synthetic> val x2: O.Foo[A] = (x1.asInstanceOf[O.Foo[A]]: O.Foo[A])) : O.Foo[A]` refers to a out-of-scope symbol, type A in class Foo. tree.symbol.ownerChain: value x2, method equals$extension, object Foo, object O, package <empty>, package <root>
    [check: extmethods] The symbol, tpe or info of tree `(<synthetic> val Foo$1: O.Foo[A] = x$1.asInstanceOf[O.Foo[A]]) : O.Foo[A]` refers to a out-of-scope symbol, type A in class Foo. tree.symbol.ownerChain: value Foo$1, method equals$extension, object Foo, object O, package <empty>, package <root>
    [check: extmethods] The symbol, tpe or info of tree `(Foo$1) : O.Foo[A]` refers to a out-of-scope symbol, type A in class Foo. tree.symbol.ownerChain: value Foo$1, method equals$extension, object Foo, object O, package <empty>, package <root>
    error: TreeCheckers detected non-compliant trees in t6891.scala
    one error found
SI-6891 Fix value class + tailrec crasher.

rhs.substituteSymbols(old, new) leaves us with:

    def loop#12225(x#12226: A#15491): scala#21.this.Unit#1615 =
      loop#12225(x#12226)

In which the TermSymbol x#12226 has a stale info, pointing at
the A#7274, the class type parameter, rather than A#15491,
the corresponding type parameter of the synthetic backing
method.

I've improved `TreeSymSubstituter` to substitute not
only `Tree#{tpe, symbol}`, but also `DefTree#sym.info`.

The `pos` test that triggered the new code path are
listed here: https://gist.github.com/4575687

AFAICS, no special treatment of Function, Return, or Import
is needed in TreeSymSubstutor.
[backport] SI-3577 BoundedWildcardType handling

commit 3c91b32d699a9e29d685ac20c9805f96c9f2db2c
Author: Jason Zaugg <jzaugg@gmail.com>
Date:   Fri Aug 24 01:16:47 2012 +0200

    Mention BoundedWildcardType in "a standard type pattern match".
    (cherry picked from commit 00e46b3dbcea2b72fd3941b7ffc2efba382871e9)

commit 0664be2b69b1ce013e937bc93f4e84b891676f1f
Author: Jason Zaugg <jzaugg@gmail.com>
Date:   Fri Aug 24 01:05:07 2012 +0200

    Make RefChecks#validateVariance aware of BoundedWildcardType.

    The only test case that I know for this will be neutered
    by the imminent fix for SI-6258; so I haven't been able to
    test this.

    But trying this manually, you can see that this patch defers the
    the SI-6258 to the erasure phase.

    Original:

    scala.MatchError: ? (of class scala.reflect.internal.Types$BoundedWildcardType)
    	at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer$$anon$3.scala$tools$nsc$typechecker$RefChecks$RefCheckTransformer$$anon$$validateVariance$1(RefChecks.scala:894)
    	at scala.tools.nsc.typechecker.RefChecks$RefCheckTransformer$$anon$3.validateVariance(RefChecks.scala:965)

    Modified:

    java.lang.ClassCastException: scala.reflect.internal.Types$TypeRef$$anon$6 cannot be cast to scala.reflect.internal.Types$TypeBounds
    	at scala.reflect.internal.Types$TypeMap.mapOver(Types.scala:4160)
    	at scala.reflect.internal.transform.Erasure$ErasureMap.apply(Erasure.scala:156)
    (cherry picked from commit 2b4e7183fd24113cca5e868456668fd05c848168)

commit 6ad651c94faf463133c742feb2aee59ef782ea1f
Author: Jason Zaugg <jzaugg@gmail.com>
Date:   Fri Aug 24 00:54:59 2012 +0200

    SI-3577 Make varianceInType aware of BoundedWildcardType.
    (cherry picked from commit 21105654c40ed0c462142bcbb6c8eced77f8b07a)
Merge pull request #1936 from retronym/ticket/6891

SI-6891 Fix value class + tailrec crasher.
Merge pull request #1981 from retronym/backport/1187

[backport] SI-3577 BoundedWildcardType handling
refactor: prepare null check redundancy analysis

this commit doesn't change any behavior
analyze extractor type test, drop redundant null check

pattern matching on case classes where the scrutinee
is not known to be a subclass of the pattern type
would result in code like:

```
if (x1.isInstanceOf[Foo]) {
  val x2 = x1.asInstanceOf[Foo]
  if (x2 != null) {
    ...
  }
}
```

this wastes byte code on the redundant null check
with this patch, it's no longer emitted when
previous type tests imply the variable cannot be null
move checker strategy to TypeTestTreeMaker