repr: add support for trait objects

Closes #8916