Change definition of isLegalPrefix so that it allows projecting on an abstract type.

This is needed to make the encoding og higher-kinded types work. E.g.

    Rep[Int]

would be represented as

    Rep { type Arg$0 = Int } # Apply

where Apply is an abstract member of the base class Lambfa$I of Rep.
Names and definitions for Lambdas

Adding names and definitions for the Lambda scheme to hk types.
Also add HigherKinded flag for HK type parameters and abstract types.
Add isLambda... tests

Testing whether a type is (a subtype of) a Lambda class.
Fixing hashing for RefinedThis types.

... to bring it in sync with equals.
Fix RefinementType#member

Type members used to always pick the last refined info for a type name.
This is incorrect, as a type might have several refinements for the
same type name, which are not necessarily subsumed by the last one.
We now only pick the last one if it is an alias type (assuming we check
for conflicts elsewhere).
Optionally check variance of Lambda classes.

Make sure that Lambda Arg refinements have the same variance as the Lambda classes
they instantiate. Controlled by a Config parameter.
Make Lambda#Apply a type field instead of a type parameter.

Apply cannot be treated as a type parameter because it does not count
towards the number of legal arguments in an instantiation of a higher-kinded
type.
Harden allOverriddenSymbols

Now also works for symbols that are not class members (and returns
Iterator.empty for them).
More careful with lookupRefined

Avoid to reduce projections `A{ ... }#T` to aliases if the
alias would refer to abstract members of the refinement type.
Fix to printing type parameters.

Printing a type parameter reference `A#T` now only reduces to `T` if
`A` is some `B.this.type`.
More explanations for -Ycheck failures.

In case of "types differ" failure, explain why original and retyped type are
not subtypes of each other.
Fixing subtyping of refined types

Refined type subtyping needs to take into account all information
that was seen about members of both refined types. This is handled by
storing context info in `pendingRefinedBases` and making use of this
to selective rebase qualifiers when comparing refined types.

Note: This commit fails in pos/collections and dotc/ast, presumably because
of bad interaction between the refined subtyping and the "matchingNames" logic
(which will go away).
Handling higher-kinded types with lambdas

Switch to the new scheme where higher-kinded types (and also some polymorphic
type aliases) are represented as instances of Lambda traits.
Delete old, disabled code in TypeComparer
Prevent a source of CyclicReference in refined printer
Fixes to lambda abstraction

1) Honor variance of Apply and $hkArgs when instantiating them
2) Eta-lifting a higher-kinded type is straight eta expansion,
   no arguments are applied.
Add missing case where isHKSubType is needed

Was not called when comparing a named type with an #Apply projection. The commit fixes this.
Make refines work for aliases

refines needs to be made more stable, so that also aliases and derefernces typevars are recognized as prefixes.
Avoid caching values that depend on typevar state.

TypeVars flip from the initial state, where underlying == origin to the final state
where underlying == inst. This flip can invalidate information that depends on the underlying
type of a TypeVar. Since we do not know when the flip occurs, we need to avoid keeping
any such information in a cache.

The commit makes three caches depend on a new value: typerState.ephemeral. The value is
set to `true` each time we follow the underlying type of a TypeVar, and this disables cached
information to be retained.

A test case for this commit is t2693.scala. This test passes typechecking with the previous commit,
but fails in -Ycheck:front because of stale cache info in an "#Apply" typeref. The present commit fixes that.
Avoid crashing on name tests when name is empty.

Guard every occurrence of name.head with a test whether name.length > 0