allow `apply_type_tfunc` to handle argtypes with `Union` (#56617)
This is an alternative to JuliaLang/julia#56532 and can resolve #31909.
Currently `apply_type_tfunc` is unable to handle `Union`-argtypes with
any precision. With this change, `apply_type_tfunc` now performs
union-splitting on `Union`-argtypes and returns the merged result of the
splits.
While this can improve inference precision, we might need to be cautious
about potential inference time bloat.
---------
Co-authored-by: Jameson Nash <vtjnash@gmail.com>