Eliminate TypeTrees with null original.

This is a retry of #2801 after figuring out the range position
error. Should there be anyone out there who compiles with -Xdev,
know that this commit eliminates the 1406 errors one presently
incurs compiling src/library.

A val declared in source code receives only one tree from the
parser, but two are needed - one for the field and one for the
getter. I discovered long ago that if the val had an existential
type, this was creating issues with incompatible existentials
between the field and the getter. However the remedy for that
did not take into account the whole of the wide range of super
subtle issues which accompany tree duplication.

In particular, the duplicated tree must be given not only a
fresh TypeTree(), but that TypeTree cannot share the same
original without running afoul of range position invariants.
That's because typedTypeTree resurrects the original tree with
whatever position it has - so the "original" needs to be a
duplicate of the original with a focused position.

Should the call to TypeTree.duplicate also duplicate the original?
I think so, but I bequeath this question to others.

This commit also eliminated some duplicate error messages, because
duplicate suppression depends on the errors having the same position.

See c478eb770d, 7a6fa80937 for previous related work.
Avoid needless Type stringification when logging is disabled.

Since 4d6be05c28, we've been a tad wasteful in implicit searches.

This adds a by-name parameter to the local logging method to
avoid that.
SI-7817 Tests to show the foibles of mkAttributedRef

To `package`, or not `package`, that is the question.

This lines marked with !!! get this wrong, and be remedied
by the next commit.

This problem is culpable for the crash in the enclosed `pending` test.
SI-7817 Fix regression in structural types

Calls to structural types are converted to reflective calls
in the `cleanup` phase, which, along with `mixin`, does its work
after `flatten`.

`Symbol#owner` behaves in a phase dependent manner; after flatten
the owner of lifted class is given as the enclosing package.

Except when they're not.

`ModuleSymbol`s representing an object nested inside a class
are viewed dually as modules *and* methods (see the comments on
`isModuleNotMethod` for some background). When it comes time to
flatten, we're presented with a quandary: the method must clearly
stay owned by the enclosing class, but surely the lifted module
should be owned by the enclosing package, to have the same owner
as its associated module class.

The `method` nature of this symbol seems to win:

    override def owner = {
      if (Statistics.hotEnabled) Statistics.incCounter(ownerCount)
      if (!isMethod && needsFlatClasses) rawowner.owner
      else rawowner

This wrinkle leads to a wrong turn in `TreeGen#mkAttributedRef`,
which incorrectly rewrites `REF(O)` to `p1.`package`.O`. It seems
this problem has gone unnoticed because the tree emitted referred
to a static symbol (the reflection cache for structural types),
and the backend simply elided the qualifier `p1.package`.

A recent change to the backend makes it more conservative about
dropping qualifiers on the floor, and it started emitting a reference
to a package object that doesn't exist.

This commit despairingly checks `isDefinedInPackage` of both the
module *and* the module class. The test cases from the previous
commit illustrated the status quo, and this commit updates the
joint compilation test with the bug fix. A new test is to show that
the symptom (structural type crash) is now fixed.
Noise reduction + minor enhance in TreeCheckers.

Misc irrelevant work, which I can only offer as-is. It lowers
the noise in -Ycheck:* output and performs some common sense
chillaxes like not screaming ERROR IN INTERNAL CHECKING! WE'RE
ALL GOING TO DIE! when a tree doesn't hit all nine points at
the Jiffy Tree.

You can see some reasonably well reduced symbol flailing if
you run the included pending tests:

  test/partest --show-diff test/pending/pos/treecheckers

Example output,

Out of scope symbol reference {
      tree  TypeTree             Factory[Traversable]
  position  OffsetPosition       test/pending/pos/treecheckers/c5.scala:3
  with sym  ClassSymbol          Factory: Factory[CC]
   and tpe  ClassArgsTypeRef     Factory[Traversable]
   encl(1)  ModuleSymbol         object Test5
    ref to  AbstractTypeSymbol   X (<deferred> <param>)
}
Avoid spurious tree checker warning for higher order type params

TreeCheckers is trying to find references to a) local types
(term owned) or b) to type parameters from a trees that are
not ancestors of the a) term or b) type param owner. Such
references are ill-scoped and suggest that a tree has been
transplanted without proper substitution.

However, this check failed to account for higher order type
parameters, as seen in the spurious warning emitted by:

    test/pending/pos/treecheckers/c5.scala.
SI-7810 Reflect private constructor

`JavaMirror.constructorToJava` uses `getDeclaredConstructor` now
instead of `getConstructor`.
add toolbox-based utility methods to quasiquotes' tests
refactor definition tests into separate subsuite
add missing copyTypeDef utility function
rename mkAnnotationCtor into mkAnnotation
merge flagsFromBits and FlagsAsBits into FlagsRepr
use NoMods and NoFlags for reification of empty values
move mkNew from tools.nsc.ast.TreeGen to reflect.internal.TreeGen

This is needed for quasiquotes to implement SyntacticNew combinator.
minor changes to TreeGen.mkTemplate

1. Make superPos parameter optional with default value NoPosition
2. use Option instead of List for local optional constructor variable
reduce amount of clutter on -Yquasiquote-debug
SI-7196 add support for refineStat splicing and extraction
refine block and applied/typeapplied splicing/matching semantics

1. blocks now match single term-level expressions to account for
   automatic block elimination. E.g.

   val q"{ ..$stats }" = q"foo"

   will match into stats = List(q"foo"). This is useful to uniformly
   deal with blocks on term level.

2. blocks in quasiquotes collapse into single expressions

3. Applied and TypeApplied now have constructors too which helps
   to unify matching and extraction in quasiquote reifier

4. TypeApplied now matches AppliedTypeTree too

5. Add Syntactic prefix to Applied and TypeApplied
reify ScalaPackage symbol with the help of ScalaDot
add support for function type splicing and extraction