diff --git a/base/namedtuple.jl b/base/namedtuple.jl index e489508bc55ea..37514ec450013 100644 --- a/base/namedtuple.jl +++ b/base/namedtuple.jl @@ -183,16 +183,15 @@ nextind(@nospecialize(t::NamedTuple), i::Integer) = Int(i)+1 convert(::Type{NT}, nt::NT) where {names, NT<:NamedTuple{names}} = nt convert(::Type{NT}, nt::NT) where {names, T<:Tuple, NT<:NamedTuple{names,T}} = nt -function convert(::Type{NT}, nt::NamedTuple{names}) where {names, T<:Tuple, NT<:NamedTuple{names,T}} - if !@isdefined T - # converting abstract NT to an abstract Tuple type, to a concrete NT1, is not straightforward, so this could just be an error, but we define it anyways - # _tuple_error(NT, nt) - T1 = Tuple{ntuple(i -> fieldtype(NT, i), Val(length(names)))...} - NT1 = NamedTuple{names, T1} - else - T1 = T - NT1 = NT - end +function convert(::Type{NamedTuple{names,T}}, nt::NamedTuple{names}) where {names,T<:Tuple} + NamedTuple{names,T}(T(nt))::NamedTuple{names,T} +end + +function convert(::Type{NT}, nt::NamedTuple{names}) where {names, NT<:NamedTuple{names}} + # converting abstract NT to an abstract Tuple type, to a concrete NT1, is not straightforward, so this could just be an error, but we define it anyways + # _tuple_error(NT, nt) + T1 = Tuple{ntuple(i -> fieldtype(NT, i), Val(length(names)))...} + NT1 = NamedTuple{names, T1} return NT1(T1(nt))::NT1::NT end diff --git a/src/subtype.c b/src/subtype.c index efff6218dfb71..c67beecae9dbd 100644 --- a/src/subtype.c +++ b/src/subtype.c @@ -941,8 +941,8 @@ static int subtype_unionall(jl_value_t *t, jl_unionall_t *u, jl_stenv_t *e, int8 jl_value_t *vl = btemp->lb; // TODO: this takes a significant amount of time if (btemp->depth0 != vb.depth0 && - ((vu != (jl_value_t*)vb.var && btemp->var->ub != vu && var_occurs_invariant(vu, vb.var)) || - (vl != (jl_value_t*)vb.var && btemp->var->lb != vl && var_occurs_invariant(vl, vb.var)))) { + ((vu != (jl_value_t*)vb.var && btemp->var->ub != vu && var_occurs_inside(vu, vb.var, 0, 0)) || + (vl != (jl_value_t*)vb.var && btemp->var->lb != vl && var_occurs_inside(vl, vb.var, 0, 0)))) { ans = 0; break; } btemp = btemp->prev; diff --git a/stdlib/LinearAlgebra/src/bidiag.jl b/stdlib/LinearAlgebra/src/bidiag.jl index 756b991c72a07..fcb098a005510 100644 --- a/stdlib/LinearAlgebra/src/bidiag.jl +++ b/stdlib/LinearAlgebra/src/bidiag.jl @@ -214,7 +214,7 @@ Matrix(A::Bidiagonal{T}) where {T} = Matrix{promote_type(T, typeof(zero(T)))}(A) Array(A::Bidiagonal) = Matrix(A) promote_rule(::Type{Matrix{T}}, ::Type{<:Bidiagonal{S}}) where {T,S} = @isdefined(T) && @isdefined(S) ? Matrix{promote_type(T,S)} : Matrix -promote_rule(::Type{Matrix}, ::Type{<:Bidiagonal}) = Matrix +promote_rule(::Type{<:Matrix}, ::Type{<:Bidiagonal}) = Matrix #Converting from Bidiagonal to Tridiagonal function Tridiagonal{T}(A::Bidiagonal) where T diff --git a/test/subtype.jl b/test/subtype.jl index 19901897ebaaa..a57ee2f23cb9b 100644 --- a/test/subtype.jl +++ b/test/subtype.jl @@ -1436,6 +1436,9 @@ struct A23764_2{T, N, S} <: AbstractArray{Union{Ref{T}, S}, N}; end @test Tuple{A23764_2{T, 1, Nothing} where T} <: Tuple{AbstractArray{T,N}} where {T,N} @test Tuple{A23764_2{T, 1, Nothing} where T} <: Tuple{AbstractArray{T,N} where {T,N}} +# issue #50716 +@test !<:(Ref{Vector{Tuple{K}} where K}, Ref{<:Vector{K}} where K) + # issue #26131 @test !(Vector{Vector{Number}} <: Vector{Union{Vector{Number}, Vector{S}}} where S<:Integer)