Merge remote-tracking branch 'origin/master' into topic/palladium0-full
SI-6732 deprecates internal#Symbol.isPackage

This is the first step in disentangling api#Symbol.isPackage, which is
supposed to return false for package classes, and internal#Symbol.isPackage,
which has traditionally being used as a synonym for hasPackageFlag and
hence returned true for package classes (unlike isModule which is false
for module classes).
deprecates String => Name implicit conversions

Given that in 2.11 we have upgraded our name construction facility
from `newTxxxName` to `TxxxName`, I think it’s time we retire these
implicit conversions, as they no longer save keystrokes, but continue
to present ambient danger associated with implicit conversions.
deprecates api#Name.decoded and api#Name.encoded

Presence of both decoded/encoded and decodedName/encodedName has always
baffled me, as one of those method groups is clearly redundant, and
this pull request presents a great opportunity to address this by
deprecating one of the groups.

After some deliberation, I’ve chosen decoded/encoded as the deprecation
target, because its derivation from decodedName/encodedName is easier
than the other way around.
cleans up Trees a little bit

Adds some clarifications to docs, introduces personally long-awaited
treeCopy.RefTree that lets us deal with RefTrees in a fully uniform fashion.
establishes scala.reflect.api#internal

Reflection API exhibits a tension inherent to experimental things:
on the one hand we want it to grow into a beautiful and robust API,
but on the other hand we have to deal with immaturity of underlying mechanisms
by providing not very pretty solutions to enable important use cases.

In Scala 2.10, which was our first stab at reflection API, we didn't
have a systematic approach to dealing with this tension, sometimes exposing
too much of internals (e.g. Symbol.deSkolemize) and sometimes exposing
too little (e.g. there's still no facility to change owners, to do typing
transformations, etc). This resulted in certain confusion with some internal
APIs living among public ones, scaring the newcomers, and some internal APIs
only available via casting, which requires intimate knowledge of the
compiler and breaks compatibility guarantees.

This led to creation of the `internal` API module for the reflection API,
which provides advanced APIs necessary for macros that push boundaries
of the state of the art, clearly demarcating them from the more or less
straightforward rest and providing compatibility guarantees on par with
the rest of the reflection API.

This commit does break source compatibility with reflection API in 2.10,
but the next commit is going to introduce a strategy of dealing with that.
reflection API compatibility with 2.10.x

This is just one of the possible strategies for compatibility with
reflection API of 2.10.x family. Here’s the discussion:

1) Do nothing.

Document the fact that we’ve organized internal APIs in a separate module
and let people figure out themselves.

Pros: no boilerplate on our side.
Cons: potential for confusion, major upfront migration effort.

2) (This commit). Introduce a compatibility pack with a manual import.
Compatibility pack lives in a separate module that has to be manually imported.
People will get compilation errors when trying to compile macros using
internal APIs against 2.11, but those will be quenched by a single
`import compat._` import. Compatibility stubs would still produce
deprecation warnings, but people can choose to ignore them to alleviate
migration costs.

Pros: brings attention of the users to the fact that they are using
internal APIs by providing a more powerful nudge than just deprecation.
Cons: even though migration effort is trivial, it is still non-zero.

3) Deprecate internal APIs in-place.

Pros: zero migration effort required.
Cons: those who ignore deprecations will be unaware about using internal APIs,
there will be some naming conflicts between Universe.xxxType and internal.xxxType
type factories.
adds Symbol.alternatives

As per Jason’s additional request, this commit exposes alternatives
in the base Symbol type, rather than only in TermSymbol.
adds initialize and fullyInitialize

As per Paul’s request, this commit introduces facilities to force initialization
of reflection artifacts.

Sure, initialize (actually, even fullyInitialize) is silently performed
by Symbol.typeSignature for runtime reflection, but people don’t have to
know about that.
adds Context.enclosingOwner

As per discussion at https://groups.google.com/forum/#!topic/scala-internals/nf_ooEBn6-k,
this commit introduces the new c.enclosingOwner API that is going to serve
two purposes: 1) provide a better controlled alternative to c.enclosingTree,
2) enable low-level tinkering with owner chains without having to cast
to compiler internals.

This solution is not ideal, because: 1) symbols are much more than
I would like to expose about enclosing lexical contexts (after the
aforementioned discussion I’m no longer completely sure whether exposing
nothing is the right thing to do, but exposing symbol completers is definitely
something that should be avoided), 2) we shouldn’t have to do that
low-level stuff in the first place.

However, let’s face the facts. This change represents both an improvement
over the state of the art wrt #1 and a long-awaited capability wrt #2.
I think this pretty much warrants its place in trunk in the spirit of
gradual, evolutionary development of reflection API.
adds internal.changeOwner

As per Jason’s and Mark’s request, this commit introduces `changeOwner`,
a facility to fixup symbol owner chains to prevent owner chain corruption
in macro expansions leading to crashes in LambdaLift and GenICode.

This is quite a low-level API that should only be used by expert users
to get their job done.

In the meanwhile we’ll be working on fixing the macro engine to
automatically prevent owner chain corruption in the first place:
https://groups.google.com/forum/#!topic/scala-internals/TtCTPlj_qcQ.
introduces c.internal

Sometimes universe.internal just won’t cut it (for example, when internal
APIs need access to enclosingOwner or to the typechecker), and for that
we need c.internal.

It’s totally not a problem for us in Scala, because with first-class modules
we can just inherit c.internal from c.universe.internal and have it expose
all the basic APIs automatically. Yay for Scala!
adds internal.typingTransform

As per Jason’s request, this commit introduces a facility to perform
tree transformations that know how to track current lexical context
and how to typecheck trees in that lexical context.

Interestingly enough, we can’t get away with the traditional “subclass the
Transformer” approach, because the required base transformer class is
declared in scala-compiler.jar, and our API is defined in scala-reflect.jar.

This forced me to play with an idea that we’ve discussed with Denys today
(actually, it’s already yesterday) - lightweight transformers that take
contextful HOFs. This commit is a sketch in that direction. Turning
`transform` and `typingTransform` into macros would make the API more
elegant (see the comments), but I didn’t have time to experiment.

I’m running short on time, so I haven’t had a chance to actually test this API,
but I’m still submitting the pull request to ignite a discussion.
adds internal.subpatterns

As per Denys’s request, this commit exposes the hack that we use to
obtain subpatterns of UnApply nodes. This is useful when writing
quasiquoting macros that do pattern matching.
some renamings

It’s almost 1am, so I’m only scratching the surface, mechanistically
applying the renames that I’ve written down in my notebook:
  * typeSignature => info
  * declarations => decls
  * nme/tpnme => termNames/typeNames
  * paramss => paramLists
  * allOverriddenSymbols => overrides

Some explanation is in order so that I don’t get crucified :)

1) No information loss happens when abbreviating `typeSignature` and `declarations`.
We already have contractions in a number of our public APIs (e.g. `typeParams`),
and I think it’s fine to shorten words as long as people can understand
the shortened versions without a background in scalac.

2) I agree with Simon that `nme` and `tpnme` are cryptic. I think it would
be thoughtful of us to provide newcomers with better names. To offset
the increase in mouthfulness, I’ve moved `MethodSymbol.isConstructor`
to `Symbol.isConstructor`, which covers the most popular use case for nme’s.

3) I also agree that putting `paramss` is a lot to ask of our users.
The double-“s” convention is very neat, but let’s admit that it’s just
weird for the newcomers. I think `paramLists` is a good compromise here.

4) `allOverriddenSymbols` is my personal complaint. I think it’s a mouthful
and a shorter name would be a much better fit for the public API.
addresses pull request feedback
moves Symbol.pos to public API

Seems to be useful to people, so why not expose it more widely?
SI-7044 deprecates Symbol.associatedFile

Before this commit, Symbol.associatedFile used to be broken in two ways.
Firstly, it was never autoloaded (just like we used to have flags,
privateWithin and annotations). Secondly, it was never filled in by runtime
reflection.

My first attempt at fixing those problems was, well, just fixing them.
However, its runtime implementation was based on a hacky function that
we were not very much excited about supported (see comments),
whereas its compile-time usefulness was somewhat questionable.

Therefore the second attempt at fixing this bug is deprecating the API
altogether, replacing it with `Symbol.pos.source`.

Since `Symbol.pos` isn't retained for runtime consumption,
`Symbol.pos.source` is still going to return `NoAbstractFile` as before
this commit, but that's left for future work, and suggested approach
is documented in SI-8259.
renames some methods in ReificationSupport

As per Denys's request, renames methods in ReificationSupport that are
eponymous to methods in Universe, so that we don't get nasty name
intersections.

This change is not source/binary-compatible, because we don't make any
promises about the contents of the build API. Feedback welcome.
addresses pull request feedback