Implement type substitution.