Cherry-pick some changes over from type-specialized-attrs.