Skip to content

Commit 90c1159

Browse files
committed
pure: remove incorrect or unnecessary annotations and functions
1 parent c604df0 commit 90c1159

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
@@ -257,7 +257,7 @@ end
257257

258258
# replace TypeVars in all enclosing UnionAlls with fresh TypeVars
259259
function rename_unionall(@nospecialize(u))
260-
if !isa(u,UnionAll)
260+
if !isa(u, UnionAll)
261261
return u
262262
end
263263
body = rename_unionall(u.body)
@@ -701,7 +701,7 @@ julia> f(Val(true))
701701
struct Val{x}
702702
end
703703

704-
Val(x) = (@_pure_meta; Val{x}())
704+
Val(x) = Val{x}()
705705

706706
"""
707707
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
@@ -534,31 +534,6 @@ struct type with no fields.
534534
"""
535535
issingletontype(@nospecialize(t)) = (@_pure_meta; isa(t, DataType) && isdefined(t, :instance))
536536

537-
"""
538-
Base.parameter_upper_bound(t::UnionAll, idx)
539-
540-
Determine the upper bound of a type parameter in the underlying datatype.
541-
This method should generally not be relied upon:
542-
code instead should usually use static parameters in dispatch to extract these values.
543-
544-
# Examples
545-
```jldoctest
546-
julia> struct Foo{T<:AbstractFloat, N}
547-
x::Tuple{T, N}
548-
end
549-
550-
julia> Base.parameter_upper_bound(Foo, 1)
551-
AbstractFloat
552-
553-
julia> Base.parameter_upper_bound(Foo, 2)
554-
Any
555-
```
556-
"""
557-
function parameter_upper_bound(t::UnionAll, idx)
558-
@_pure_meta
559-
return rewrap_unionall((unwrap_unionall(t)::DataType).parameters[idx], t)
560-
end
561-
562537
"""
563538
typeintersect(T, S)
564539
@@ -725,13 +700,12 @@ julia> instances(Color)
725700
function instances end
726701

727702
function to_tuple_type(@nospecialize(t))
728-
@_pure_meta
729-
if isa(t,Tuple) || isa(t,AbstractArray) || isa(t,SimpleVector)
703+
if isa(t, Tuple) || isa(t, AbstractArray) || isa(t, SimpleVector)
730704
t = Tuple{t...}
731705
end
732-
if isa(t,Type) && t<:Tuple
706+
if isa(t, Type) && t <: Tuple
733707
for p in unwrap_unionall(t).parameters
734-
if !(isa(p,Type) || isa(p,TypeVar))
708+
if !(isa(p, Type) || isa(p, TypeVar))
735709
error("argument tuple type must contain only types")
736710
end
737711
end

base/tuple.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function _compute_eltype(t::Type{<:Tuple})
118118
@nospecialize t
119119
t isa Union && return promote_typejoin(eltype(t.a), eltype(t.b))
120120
= unwrap_unionall(t)
121+
# TODO: handle Union/UnionAll correctly here
121122
r = Union{}
122123
for ti in.parameters
123124
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
@@ -799,12 +799,6 @@ fUnionAll(::Type{T}) where {T} = Type{S} where S <: T
799799
@inferred fUnionAll(Real) == Type{T} where T <: Real
800800
@inferred fUnionAll(Rational{T} where T <: AbstractFloat) == Type{T} where T<:(Rational{S} where S <: AbstractFloat)
801801

802-
fComplicatedUnionAll(::Type{T}) where {T} = Type{Tuple{S,rand() >= 0.5 ? Int : Float64}} where S <: T
803-
let pub = Base.parameter_upper_bound, x = fComplicatedUnionAll(Real)
804-
@test pub(pub(x, 1), 1) == Real
805-
@test pub(pub(x, 1), 2) == Int || pub(pub(x, 1), 2) == Float64
806-
end
807-
808802
# issue #20733
809803
# run this test in a separate process to avoid interfering with `getindex`
810804
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
@@ -559,10 +559,6 @@ end
559559
@test !isstructtype(Int)
560560
@test isstructtype(TLayout)
561561

562-
@test Base.parameter_upper_bound(ReflectionExample, 1) === AbstractFloat
563-
@test Base.parameter_upper_bound(ReflectionExample, 2) === Any
564-
@test Base.parameter_upper_bound(ReflectionExample{T, N} where T where N <: Real, 2) === Real
565-
566562
let
567563
wrapperT(T) = Base.typename(T).wrapper
568564
@test @inferred wrapperT(ReflectionExample{Float64, Int64}) == ReflectionExample

0 commit comments

Comments
 (0)