diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 4ebe377e091e6..8275c2e6865da 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -2044,6 +2044,7 @@ function form_partially_defined_struct(@nospecialize(obj), @nospecialize(name)) name isa Const || return nothing objt0 = widenconst(obj) objt = unwrap_unionall(objt0) + objt isa DataType || return nothing isabstracttype(objt) && return nothing fldidx = try_compute_fieldidx(objt, name.val) fldidx === nothing && return nothing @@ -3109,7 +3110,8 @@ end @nospecializeinfer function widenreturn_partials(๐•ƒแตข::PartialsLattice, @nospecialize(rt), info::BestguessInfo) if isa(rt, PartialStruct) fields = copy(rt.fields) - anyrefine = !isvarargtype(rt.fields[end]) && length(rt.fields) > datatype_min_ninitialized(rt.typ) + anyrefine = !isvarargtype(rt.fields[end]) && + length(rt.fields) > datatype_min_ninitialized(unwrap_unionall(rt.typ)) ๐•ƒ = typeinf_lattice(info.interp) โŠ = strictpartialorder(๐•ƒ) for i in 1:length(fields) diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index 2af729ceec473..f1e3b550f67db 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -1005,7 +1005,7 @@ end nflds = nfields(sv) ismod = sv isa Module elseif isa(s00, PartialStruct) - sty = s00.typ + sty = unwrap_unionall(s00.typ) nflds = fieldcount_noerror(sty) ismod = false else diff --git a/test/tuple.jl b/test/tuple.jl index 59897c8adfdb2..f7481cc4f5150 100644 --- a/test/tuple.jl +++ b/test/tuple.jl @@ -533,7 +533,7 @@ end @test ntuple(identity, Val(n)) == ntuple(identity, n) end - @test Core.Compiler.return_type(ntuple, Tuple{typeof(identity), Val}) == Tuple{Vararg{Int}} + @test Base.infer_return_type(ntuple, Tuple{typeof(identity), Val}) == Tuple{Vararg{Int}} end struct A_15703{N} @@ -835,8 +835,8 @@ end @test @inferred(Base.circshift(t3, 7)) == ('b', 'c', 'd', 'a') @test @inferred(Base.circshift(t3, -1)) == ('b', 'c', 'd', 'a') @test_throws MethodError circshift(t1, 'a') - @test Core.Compiler.return_type(circshift, Tuple{Tuple,Integer}) <: Tuple - @test Core.Compiler.return_type(circshift, Tuple{Tuple{Vararg{Any,10}},Integer}) <: Tuple{Vararg{Any,10}} + @test Base.infer_return_type(circshift, Tuple{Tuple,Integer}) <: Tuple + @test Base.infer_return_type(circshift, Tuple{Tuple{Vararg{Any,10}},Integer}) <: Tuple{Vararg{Any,10}} for len โˆˆ 0:5 v = 1:len t = Tuple(v) @@ -847,8 +847,8 @@ end end @testset "abstract return type inference for homogeneous tuples" begin - @test NTuple == Core.Compiler.return_type(Base.tail, Tuple{NTuple}) - @test NTuple == Core.Compiler.return_type(Base.front, Tuple{NTuple}) - @test NTuple == Core.Compiler.return_type(reverse, Tuple{NTuple}) - @test NTuple == Core.Compiler.return_type(circshift, Tuple{NTuple,Int}) + @test NTuple == Base.infer_return_type(Base.tail, Tuple{NTuple}) + @test NTuple == Base.infer_return_type(Base.front, Tuple{NTuple}) + @test NTuple == Base.infer_return_type(reverse, Tuple{NTuple}) + @test NTuple == Base.infer_return_type(circshift, Tuple{NTuple,Int}) end