Skip to content

Commit aa28710

Browse files
committed
pure: remove incorrect or unnecessary annotations and functions
1 parent 5777e22 commit aa28710

File tree

7 files changed

+9
-48
lines changed

7 files changed

+9
-48
lines changed

base/bool.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ julia> .![true false true]
3030
0 1 0
3131
```
3232
"""
33-
function !(x::Bool)
34-
## We need a better heuristic to detect this automatically
35-
@_pure_meta
36-
return not_int(x)
37-
end
33+
!(x::Bool) = not_int(x)
3834

3935
(~)(x::Bool) = !x
4036
(&)(x::Bool, y::Bool) = and_int(x, y)

base/essentials.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ end
218218

219219
# replace TypeVars in all enclosing UnionAlls with fresh TypeVars
220220
function rename_unionall(@nospecialize(u))
221-
if !isa(u,UnionAll)
221+
if !isa(u, UnionAll)
222222
return u
223223
end
224224
body = rename_unionall(u.body)
@@ -658,7 +658,7 @@ julia> f(Val(true))
658658
struct Val{x}
659659
end
660660

661-
Val(x) = (@_pure_meta; Val{x}())
661+
Val(x) = Val{x}()
662662

663663
"""
664664
invokelatest(f, args...; kwargs...)

base/promotion.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
Return the closest common ancestor of `T` and `S`, i.e. the narrowest type from which
1010
they both inherit.
1111
"""
12-
typejoin() = (@_pure_meta; Bottom)
13-
typejoin(@nospecialize(t)) = (@_pure_meta; t)
12+
typejoin() = Bottom
13+
typejoin(@nospecialize(t)) = t
1414
typejoin(@nospecialize(t), ts...) = (@_pure_meta; typejoin(t, typejoin(ts...)))
1515
function typejoin(@nospecialize(a), @nospecialize(b))
1616
@_pure_meta

base/reflection.jl

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -541,31 +541,6 @@ struct type with no fields.
541541
"""
542542
issingletontype(@nospecialize(t)) = (@_pure_meta; isa(t, DataType) && isdefined(t, :instance))
543543

544-
"""
545-
Base.parameter_upper_bound(t::UnionAll, idx)
546-
547-
Determine the upper bound of a type parameter in the underlying datatype.
548-
This method should generally not be relied upon:
549-
code instead should usually use static parameters in dispatch to extract these values.
550-
551-
# Examples
552-
```jldoctest
553-
julia> struct Foo{T<:AbstractFloat, N}
554-
x::Tuple{T, N}
555-
end
556-
557-
julia> Base.parameter_upper_bound(Foo, 1)
558-
AbstractFloat
559-
560-
julia> Base.parameter_upper_bound(Foo, 2)
561-
Any
562-
```
563-
"""
564-
function parameter_upper_bound(t::UnionAll, idx)
565-
@_pure_meta
566-
return rewrap_unionall((unwrap_unionall(t)::DataType).parameters[idx], t)
567-
end
568-
569544
"""
570545
typeintersect(T, S)
571546
@@ -730,13 +705,12 @@ julia> instances(Color)
730705
function instances end
731706

732707
function to_tuple_type(@nospecialize(t))
733-
@_pure_meta
734-
if isa(t,Tuple) || isa(t,AbstractArray) || isa(t,SimpleVector)
708+
if isa(t, Tuple) || isa(t, AbstractArray) || isa(t, SimpleVector)
735709
t = Tuple{t...}
736710
end
737-
if isa(t,Type) && t<:Tuple
711+
if isa(t, Type) && t <: Tuple
738712
for p in unwrap_unionall(t).parameters
739-
if !(isa(p,Type) || isa(p,TypeVar))
713+
if !(isa(p, Type) || isa(p, TypeVar))
740714
error("argument tuple type must contain only types")
741715
end
742716
end

base/tuple.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ function _compute_eltype(t::Type{<:Tuple})
9999
@_pure_meta
100100
t isa Union && return promote_typejoin(eltype(t.a), eltype(t.b))
101101
= unwrap_unionall(t)
102+
# TODO: handle Union/UnionAll correctly here
102103
r = Union{}
103104
for ti in.parameters
104105
r = promote_typejoin(r, rewrap_unionall(unwrapva(ti), t))

test/compiler/inference.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -772,12 +772,6 @@ fUnionAll(::Type{T}) where {T} = Type{S} where S <: T
772772
@inferred fUnionAll(Real) == Type{T} where T <: Real
773773
@inferred fUnionAll(Rational{T} where T <: AbstractFloat) == Type{T} where T<:(Rational{S} where S <: AbstractFloat)
774774

775-
fComplicatedUnionAll(::Type{T}) where {T} = Type{Tuple{S,rand() >= 0.5 ? Int : Float64}} where S <: T
776-
let pub = Base.parameter_upper_bound, x = fComplicatedUnionAll(Real)
777-
@test pub(pub(x, 1), 1) == Real
778-
@test pub(pub(x, 1), 2) == Int || pub(pub(x, 1), 2) == Float64
779-
end
780-
781775
# issue #20733
782776
# run this test in a separate process to avoid interfering with `getindex`
783777
let def = "Base.getindex(t::NTuple{3,NTuple{2,Int}}, i::Int, j::Int, k::Int) = (t[1][i], t[2][j], t[3][k])"

test/reflection.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,6 @@ end
572572
@test !isstructtype(Int)
573573
@test isstructtype(TLayout)
574574

575-
@test Base.parameter_upper_bound(ReflectionExample, 1) === AbstractFloat
576-
@test Base.parameter_upper_bound(ReflectionExample, 2) === Any
577-
@test Base.parameter_upper_bound(ReflectionExample{T, N} where T where N <: Real, 2) === Real
578-
579575
let
580576
wrapperT(T) = Base.typename(T).wrapper
581577
@test @inferred wrapperT(ReflectionExample{Float64, Int64}) == ReflectionExample

0 commit comments

Comments
 (0)