Better const handling when the RHS is inferred

this fixes some (all?) of the issues pointed out in the discussion of https://github.com/google/closure-compiler/pull/402