diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index 859935bd916ea..cc13d5e3e1f49 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -1144,7 +1144,7 @@ function apply_type_tfunc(@nospecialize(headtypetype), @nospecialize args...) end return allconst ? Const(ty) : Type{ty} end - istuple = (headtype == Tuple) + istuple = isa(headtype, Type) && (headtype == Tuple) if !istuple && !isa(headtype, UnionAll) return Union{} end diff --git a/test/compiler/inference.jl b/test/compiler/inference.jl index 6d1986e1fbecf..2540d3c870e73 100644 --- a/test/compiler/inference.jl +++ b/test/compiler/inference.jl @@ -2985,3 +2985,8 @@ g38888() = S38888(Base.inferencebarrier(3), nothing) # issue #38971 f28971() = (1, [2,3]...)::Tuple{Int,Int,Int} @test @inferred(Tuple{Int,Vararg{Int}}, f28971()) == (1, 2, 3) + +# issue #39862 +let f() = sin{Int}() + @test Base.return_types(f, ()) == Any[Union{}] +end