Improve code reuse in check_match::specialize()