Improve inference of encodeOnly