Skip to content

Commit 10c0cfd

Browse files
committed
Rollback non-bugfix parts
1 parent cd39cf7 commit 10c0cfd

File tree

5 files changed

+10
-33
lines changed

5 files changed

+10
-33
lines changed

base/bool.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# promote Bool to any other numeric type
44
promote_rule(::Type{Bool}, ::Type{T}) where {T<:Number} = T
55

6-
convert(::Type{Bool}, x::Bool) = x # prevent invalidation
7-
86
typemin(::Type{Bool}) = false
97
typemax(::Type{Bool}) = true
108

base/char.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ Char
4949
(::Type{AbstractChar})(x::Number) = Char(x)
5050
(::Type{T})(x::AbstractChar) where {T<:Union{Number,AbstractChar}} = T(codepoint(x))
5151
(::Type{T})(x::T) where {T<:AbstractChar} = x
52-
AbstractChar(x::AbstractChar) = x
5352

5453
"""
5554
ncodeunits(c::Char) -> Int
@@ -180,7 +179,6 @@ convert(::Type{AbstractChar}, x::Number) = Char(x) # default to Char
180179
convert(::Type{T}, x::Number) where {T<:AbstractChar} = T(x)
181180
convert(::Type{T}, x::AbstractChar) where {T<:Number} = T(x)
182181
convert(::Type{T}, c::AbstractChar) where {T<:AbstractChar} = T(c)
183-
convert(::Type{AbstractChar}, c::AbstractChar) = c
184182
convert(::Type{T}, c::T) where {T<:AbstractChar} = c
185183

186184
rem(x::AbstractChar, ::Type{T}) where {T<:Number} = rem(codepoint(x), T)

base/essentials.jl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,13 @@ true
166166
"""
167167
function convert end
168168

169-
convert(::Type{Union{}}, x::Union{}) = throw(MethodError(convert, (Union{}, x)))
170169
convert(::Type{Union{}}, x) = throw(MethodError(convert, (Union{}, x)))
171170
convert(::Type{Any}, x) = x
172171
convert(::Type{T}, x::T) where {T} = x
173172
convert(::Type{Type}, x::Type) = x # the ssair optimizer is strongly dependent on this method existing to avoid over-specialization
174173
# in the absence of inlining-enabled
175174
# (due to fields typed as `Type`, which is generally a bad idea)
176175

177-
Union{}(x::Union{}) = throw(MethodError(convert, (Union{}, x)))
178-
179176
"""
180177
@eval [mod,] ex
181178
@@ -450,9 +447,6 @@ Stacktrace:
450447
```
451448
"""
452449
sizeof(x) = Core.sizeof(x)
453-
# The next two methods prevent invalidation
454-
sizeof(::Type{Union{}}) = Core.sizeof(Union{})
455-
sizeof(::Type{T}) where T = Core.sizeof(T)
456450

457451
# simple Array{Any} operations needed for bootstrap
458452
@eval setindex!(A::Array{Any}, @nospecialize(x), i::Int) = arrayset($(Expr(:boundscheck)), A, x, i)

base/number.jl

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
## generic operations on numbers ##
44

5-
# prevent invalidation
6-
Union{}(x::Number) = throw(MethodError(convert, (Union{}, x)))
7-
convert(::Type{Union{}}, x::Number) = throw(MethodError(convert, (Union{}, x)))
8-
95
# Numbers are convertible
106
convert(::Type{T}, x::T) where {T<:Number} = x
117
convert(::Type{T}, x::Number) where {T<:Number} = T(x)
@@ -244,9 +240,6 @@ julia> zero(rand(2,2))
244240
"""
245241
zero(x::Number) = oftype(x,0)
246242
zero(::Type{T}) where {T<:Number} = convert(T,0)
247-
# prevent invalidation
248-
zero(x::Union{}) = throw(MethodError(zero, (x,)))
249-
zero(::Type{Union{}}) = throw(MethodError(zero, (Union{},)))
250243

251244
"""
252245
one(x)
@@ -282,9 +275,6 @@ julia> import Dates; one(Dates.Day(1))
282275
"""
283276
one(::Type{T}) where {T<:Number} = convert(T,1)
284277
one(x::T) where {T<:Number} = one(T)
285-
# prevent invalidation
286-
one(x::Union{}) = throw(MethodError(one, (x,)))
287-
one(::Type{Union{}}) = throw(MethodError(one, (Union{},)))
288278
# note that convert(T, 1) should throw an error if T is dimensionful,
289279
# so this fallback definition should be okay.
290280

@@ -308,9 +298,6 @@ julia> import Dates; oneunit(Dates.Day)
308298
"""
309299
oneunit(x::T) where {T} = T(one(x))
310300
oneunit(::Type{T}) where {T} = T(one(T))
311-
# prevent invalidation
312-
oneunit(x::Union{}) = throw(MethodError(oneunit, (x,)))
313-
oneunit(::Type{Union{}}) = throw(MethodError(oneunit, (Union{},)))
314301

315302
"""
316303
big(T::Type)

base/reduce.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ with reduction `op` over an empty array with element type of `T`.
307307
If not defined, this will throw an `ArgumentError`.
308308
"""
309309
reduce_empty(op, ::Type{T}) where T = _empty_reduce_error()
310-
reduce_empty(::typeof(+), ::Type{Union{}}) = _empty_reduce_error() # avoid invalidation
310+
reduce_empty(::typeof(+), ::Type{Union{}}) = _empty_reduce_error()
311311
reduce_empty(::typeof(+), ::Type{T}) where T = zero(T)
312312
reduce_empty(::typeof(+), ::Type{Bool}) = zero(Int)
313313
reduce_empty(::typeof(*), ::Type{Union{}}) = _empty_reduce_error()
@@ -325,10 +325,10 @@ reduce_empty(::typeof(mul_prod), ::Type{T}) where T = reduce_empty(*, T)
325325
reduce_empty(::typeof(mul_prod), ::Type{T}) where {T<:SmallSigned} = one(Int)
326326
reduce_empty(::typeof(mul_prod), ::Type{T}) where {T<:SmallUnsigned} = one(UInt)
327327

328-
reduce_empty(op::BottomRF, ::Type{T}) where T = reduce_empty(op.rf, T)
329-
reduce_empty(op::MappingRF, ::Type{T}) where T = mapreduce_empty(op.f, op.rf, T)
330-
reduce_empty(op::FilteringRF, ::Type{T}) where T = reduce_empty(op.rf, T)
331-
reduce_empty(op::FlipArgs, ::Type{T}) where T = reduce_empty(op.f, T)
328+
reduce_empty(op::BottomRF, T) = reduce_empty(op.rf, T)
329+
reduce_empty(op::MappingRF, T) = mapreduce_empty(op.f, op.rf, T)
330+
reduce_empty(op::FilteringRF, T) = reduce_empty(op.rf, T)
331+
reduce_empty(op::FlipArgs, T) = reduce_empty(op.f, T)
332332

333333
"""
334334
Base.mapreduce_empty(f, op, T)
@@ -340,12 +340,12 @@ of `T`.
340340
If not defined, this will throw an `ArgumentError`.
341341
"""
342342
mapreduce_empty(f, op, T) = _empty_reduce_error()
343-
mapreduce_empty(::typeof(identity), op, ::Type{T}) where T = reduce_empty(op, T)
344-
mapreduce_empty(::typeof(abs), op, ::Type{T}) where T = abs(reduce_empty(op, T))
345-
mapreduce_empty(::typeof(abs2), op, ::Type{T}) where T = abs2(reduce_empty(op, T))
343+
mapreduce_empty(::typeof(identity), op, T) = reduce_empty(op, T)
344+
mapreduce_empty(::typeof(abs), op, T) = abs(reduce_empty(op, T))
345+
mapreduce_empty(::typeof(abs2), op, T) = abs2(reduce_empty(op, T))
346346

347-
mapreduce_empty(::typeof(abs), ::typeof(max), ::Type{T}) where T = abs(zero(T))
348-
mapreduce_empty(::typeof(abs2), ::typeof(max), ::Type{T}) where T = abs2(zero(T))
347+
mapreduce_empty(f::typeof(abs), ::typeof(max), T) = abs(zero(T))
348+
mapreduce_empty(f::typeof(abs2), ::typeof(max), T) = abs2(zero(T))
349349

350350
# For backward compatibility:
351351
mapreduce_empty_iter(f, op, itr, ItrEltype) =

0 commit comments

Comments
 (0)