diff --git a/base/essentials.jl b/base/essentials.jl index 2093c792dd9b4..61e9b1b25800d 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -386,8 +386,10 @@ function isvatuple(@nospecialize(t)) return false end -unwrapva(t::Core.TypeofVararg) = isdefined(t, :T) ? t.T : Any -unwrapva(@nospecialize(t)) = t +function unwrapva(@nospecialize(t)) + isa(t, Core.TypeofVararg) || return t + return isdefined(t, :T) ? t.T : Any +end function unconstrain_vararg_length(va::Core.TypeofVararg) # construct a new Vararg type where its length is unconstrained, diff --git a/base/tuple.jl b/base/tuple.jl index 962a26d8fa789..219315e77944d 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -213,13 +213,12 @@ function _tuple_unique_fieldtypes(@nospecialize t) t´ = unwrap_unionall(t) # Given t = Tuple{Vararg{S}} where S<:Real, the various # unwrapping/wrapping/va-handling here will return Real - if t isa Union + if t´ isa Union union!(types, _tuple_unique_fieldtypes(rewrap_unionall(t´.a, t))) union!(types, _tuple_unique_fieldtypes(rewrap_unionall(t´.b, t))) else - r = Union{} for ti in (t´::DataType).parameters - r = push!(types, rewrap_unionall(unwrapva(ti), t)) + push!(types, rewrap_unionall(unwrapva(ti), t)) end end return Core.svec(types...)