scala/scala — pull request #3021 by paulp (2013-10-06 01:16:59+00:00)
Title: Extract isStable and isVolatile from Type.

As with finalResultType, this is easier to control
and WAY easier to understand. Look, all the relevant
code fits on half a screenful rather than being
spread out over 5000 lines and you have to be
constantly conscious of what is overriding what.

Truly it would be hard to damn the indiscriminate
use of subtype polymorphism any more soundly than
does this, by way of contrast:
```
def isStable(tp: Type): Boolean = tp match {
case _: SingletonType => true
case NoPrefix => true
case TypeRef(_, NothingClass | SingletonClass, _) => true
case TypeRef(_, sym, _) if sym.isAbstractType => tp.bounds.hi.typeSymbol isSubClass SingletonClass
case TypeRef(pre, sym, _) if sym.isModuleClass => isStable(pre)
case TypeRef(_, _, _) if tp ne tp.dealias => isStable(tp.dealias)
case TypeVar(origin, _) => isStable(origin)
case AnnotatedType(_, atp, _) => isStable(atp) // Really?
case _: SimpleTypeProxy => isStable(tp.underlying)
case _ => false
}
```
That's all of it! If there are bugs in it (of course there are)
some might even be found now.