Any workaround for this core Julia bug causing spurious `UndefVarError`?

This script succeeds as expected (run as script or try in a fresh REPL session):

f(::Type{<:Tuple{Vararg{A}}}) where {A} = A
struct S end
f(Tuple{Vararg{S}})
f(Tuple{Vararg{T}} where {T<:S})

But if the order of the calls to f is reversed, exchanging the last two lines, all calls of f fail. With any Julia version I tried.

Can anyone think of a workaround? My perspective is that I want to write a function like f that should work for all possible A, not just for known types like S.