typeof(x) is the static type of the parameter, which in turn is the static type of the argument to the test(x) call. It comes fromx = x.to_i32? || x, which can only be an Int32 or a String. The compiler would generate an instance of test that has Int32 | String parameters; if you separately call test(11) and test("sdfs") in your source code, there would be extra instantiations for Int32 and String parameters respectively. That is to say, the arguments are never upcast to Object (which is unimplemented anyway).
If you know C++, a general rule is that something like this:
def foo(x : Int32 | String)
# typeof(x) may be `Int32`, `String`, or `Int32 | String`
end
is analogous to:
void foo(std::convertible_to<std::variant<int, const char *>> auto x) {
// `decltype(x)` may be `int`, `const char *`, or many others due to implicit conversion rules
}