scala/scala — pull request #2879 by retronym (2013-08-27 14:39:15+00:00)
Title: SI-7785 Preserve TypeVar suspension through TypeMaps

During `findMember`, TypeVars in `this` are placed into suspended
animation. This is to avoid running into recursive types when
matching members to those in base classes.

However, the mechanism used to do this is superficial, and doesn't
work when TypeVars are copied by TypeMaps. This seems to crop up
when using `AppliedTypeVar` with higher-kinded type vars.

In the enclosed test case, the cyclic type led to a SOE in
CommonOwnerMap.

This commit allows a TypeVar to delegate its `suspended` attribute
to the TypeVar from which it was copied. This is done in
`TypeVar#applyArgs`, which is called by:

// TypeMap#mapOver
case tv@TypeVar(_, constr) =>
if (constr.instValid) this(constr.inst)
else tv.applyArgs(mapOverArgs(tv.typeArgs, tv.params))

We should review the other places this is called to make sure
that it make sense to link in this way:

Types#appliedType
TypeVar#normalize

Review by @adriaanm.

Even though this was a regression in 2.10.1, I'm submitting this to 2.11 as the change isn't without risk, and the only reason this worked in 2.10.0 was because of another bug (`TypeVar` had a structural equals.)