diff --git a/base/essentials.jl b/base/essentials.jl index 2e76235cba9a6..50017b3d7927d 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -501,13 +501,7 @@ julia> Base.tail(()) ERROR: ArgumentError: Cannot call tail on an empty tuple. ``` """ -function tail(x::Tuple{Any,Vararg}) - y = argtail(x...)::Tuple - if x isa NTuple # help the type inference - y = y::NTuple - end - y -end +tail(x::Tuple) = argtail(x...) tail(::Tuple{}) = throw(ArgumentError("Cannot call tail on an empty tuple.")) function unwrap_unionall(@nospecialize(a)) diff --git a/base/ntuple.jl b/base/ntuple.jl index 4adab38a8ee82..f81d2686b9764 100644 --- a/base/ntuple.jl +++ b/base/ntuple.jl @@ -95,5 +95,5 @@ end function reverse(t::NTuple{N}) where N ntuple(Val{N}()) do i t[end+1-i] - end::NTuple + end end diff --git a/base/tuple.jl b/base/tuple.jl index 5f74d486e1e69..fc213410cfd7c 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -340,15 +340,9 @@ ERROR: ArgumentError: Cannot call front on an empty tuple. """ function front(t::Tuple) @inline - if t === () - throw(ArgumentError("Cannot call front on an empty tuple.")) - end - r = _front(t...)::Tuple - if t isa NTuple # help the type inference - r = r::NTuple - end - r + _front(t...) end +_front() = throw(ArgumentError("Cannot call front on an empty tuple.")) _front(v) = () function _front(v, t...) @inline @@ -705,9 +699,5 @@ function circshift(x::Tuple{Any,Any,Any,Vararg{Any,N}}, shift::Integer) where {N @inline len = N + 3 j = mod1(shift, len) - y = ntuple(k -> getindex(x, k-j+ifelse(k>j,0,len)), Val(len))::Tuple - if x isa NTuple # help the type inference - y = y::NTuple - end - y + ntuple(k -> getindex(x, k-j+ifelse(k>j,0,len)), Val(len))::Tuple end diff --git a/test/tuple.jl b/test/tuple.jl index 59897c8adfdb2..b1894bd2bb6ce 100644 --- a/test/tuple.jl +++ b/test/tuple.jl @@ -845,10 +845,3 @@ end end 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}) -end