Properly compute the type of a Const in a selector expression.

Closes #1068
Fix a bunch of failed tests.