`@inferred` check for a small `Union` without being specific about the types

Suppose I have a function

f(x) = x > 1 ? 0 : x

For this, I obtain

julia> @code_warntype f(0.2)
MethodInstance for f(::Float64)
  from f(x) @ Main REPL[43]:1
Arguments
  #self#::Core.Const(f)
  x::Float64
Body::Union{Float64, Int64}

Now, I want to write an inference unit test, but without being specific about the types in the union. I know that this works:

julia> @inferred Union{Float64,Int} f(0.2)
0.2

I would like to write something like

@inferred (Union{A,B} where {A,B}) f(0.2)

with the additional constraint, that A and B are concretely inferred. I wonder if there’s a way to test for that the inferred type is a small union, without specifying the exact types that are to be returned?

Does Union{<:Any,<:Any} work?

julia> @inferred Union{<:Any,<:Any} iterate(1:10)
(1, 1)