Merge pull request #2932 from retronym/topic/cps-skip-locker-friendly

Revert a tiny recent refactoring in SelectiveCPSTransform
SI-7472 superior pattern type inference.

Major cleanup in type inference. Lose less information about
the type of the match scrutinee: don't widen it arbitrarily
(so a singleton type can survive match, see pos/t6771b.scala)
and preserve it through the match when the straitjacket of an
implementation allows for it.

More generally, shone some light into the darkest corners of type
inference. It's still a grim apocalyptic wasteland, but maybe the
next guy will have a better chance.

The real contribution here is to bring a sliver of abstraction
to the creation and instantiation of TypeVars. They are still
a long way from encapsulated, but feel closer now. Should
someone wish to continue this effort (assuming continuing with
the current mechanism based on mutation of TypeVars, which I
would not recommend) I advise that nothing be allowed to create
TypeVars directly. Every use of TypeVars should be encapsulated
such that the TypeVars are created on method entry and either
instantiated or discarded by method exit.
Annotate test sources with pattern inference data.

Attempting to innovate in the field of not squandering all the
hard-won knowledge from days of fiddling with the implementation,
I devised this means of making the next guy's life easier. In
this commit certain tests are annotated with comments elaborating
on how a pattern's type was inferred. The annotated tests meet
these conditions:

 - they contain a "Typed" pattern (e.g. x: Foo => ... )
 - the candidates for inference are not type-equivalent

The type of a "Typed" pattern is inferred based on the
expected type of the pattern (the type of the "scrutinee") and
the ascripted type. These types are known internally as "pt" and
"pattp", respectively. The essential candidates for the inferred
type are:

  intersect(pattp, pt)
  intersect(pt, pattp)

From this apparently simple choice arises great complication,
arising in part from the language semantics - intersections are
asymmetric - and in part from the implementation - the mutation
based approach to type inference makes it extremely difficult
to modify, e.g. simply by performing a subtype test you stand a
good chance of changing the outcome. Furthermore one faces a mix
of properly formed types and types carrying dummy type arguments,
TypeVars, Wildcards, and other constructs which don't always lead
to intuitive results for <:<.

The tiniest, most apparently irrelevant change to the key method
inferTypedPattern is(was) liable to cause a test to change behavior.
For this reason the most valuable part of this commit may be simply
a side effect of annotating all these tests at once: it is now very
easy to test these and only these, e.g.

  test/partest $(git show --pretty=format: --name-only $THIS_COMMIT_SHA)

A note on notation: the meanings of the conformance operators
are mostly self-evidence, but I had to invent two:

  a !:= b  // (a =:= b), (a <:< b), and (b <:< a) are all FALSE
  a ~:= b  // (a =:= b) is FALSE, but (a <:< b) and (b <:< a) are TRUE

That last is supposed to call to mind "approximately =:=". This
outcome, where a <:< b, b <:< a, and !(a =:= b) is actually common
at the positionm where it is being recorded.
A failing test that shows what breaks without widening.