scala/scala — pull request #695 by adriaanm (2012-06-09 12:19:51+00:00)
Title: better unreachability for selections

Consts are hashconsed modulo static-approximation-for-dynamic-value-equality
thus, two value-equality tests in patterns should reuse the same ValueConst
if and only if the tested values are guaranteed to be equal in all possible executions

the implementation uses unique types to track unique consts
for an Ident with a stable symbol, we simply use the corresponding singleton type
for a Select, we have to indirect some more: we store all the unique trees we've encountered and a unique type for each of them; this unique type is then used to find the unique const that approximates the run-time value

this may seem roundabout, but we need to standardize on types for representing "value" tests,
since a type test against a singleton type must give rise to the same ValueConst
as a value test using a tree that refers to the same symbol as the singleton type test
(also, it's easier to go from values to types than vice versa)