Fix inference of two recursive types.

Closes PR14608.