Skip to content

Commit 13da0b9

Browse files
authored
Merge pull request #19937 from TotalVerb/fw/type-stable-promote-eltype-op
Make deprecated promote_eltype_op type stable
2 parents 1494f43 + ec31934 commit 13da0b9

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

base/deprecated.jl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,7 +1242,9 @@ for (Bsig, A1sig, A2sig, gbb, funcname) in
12421242
end # let broadcast_cache
12431243
end
12441244
_broadcast_zpreserving!(args...) = broadcast!(args...)
1245-
_broadcast_zpreserving(f, As...) = broadcast!(f, similar(Array{promote_op(f, map(eltype, As)...)}, Base.Broadcast.broadcast_indices(As...)), As...)
1245+
# note: promote_eltype_op also deprecated, defined later in this file
1246+
_broadcast_zpreserving(f, As...) =
1247+
broadcast!(f, similar(Array{_promote_eltype_op(f, As...)}, Base.Broadcast.broadcast_indices(As...)), As...)
12461248
_broadcast_zpreserving{Tv1,Ti1,Tv2,Ti2}(f::Function, A_1::SparseMatrixCSC{Tv1,Ti1}, A_2::SparseMatrixCSC{Tv2,Ti2}) =
12471249
_broadcast_zpreserving!(f, spzeros(promote_type(Tv1, Tv2), promote_type(Ti1, Ti2), Base.to_shape(Base.Broadcast.broadcast_indices(A_1, A_2))), A_1, A_2)
12481250
_broadcast_zpreserving{Tv,Ti}(f::Function, A_1::SparseMatrixCSC{Tv,Ti}, A_2::Union{Array,BitArray,Number}) =
@@ -1502,8 +1504,18 @@ function frexp{T<:AbstractFloat}(A::Array{T})
15021504
return (F, E)
15031505
end
15041506

1505-
# Calling promote_op is likely a bad idea, so deprecate its convenience wrapper promote_eltype_op
1506-
@deprecate promote_eltype_op(op, As...) promote_op(op, map(eltype, As)...)
1507+
# Deprecate promote_eltype_op (#19814, #19937)
1508+
_promote_eltype_op(::Any) = Any
1509+
_promote_eltype_op(op, A) = (@_inline_meta; promote_op(op, eltype(A)))
1510+
_promote_eltype_op(op, A, B) = (@_inline_meta; promote_op(op, eltype(A), eltype(B)))
1511+
_promote_eltype_op(op, A, B, C, D...) = (@_inline_meta; _promote_eltype_op(op, eltype(A), _promote_eltype_op(op, B, C, D...)))
1512+
@inline function promote_eltype_op(args...)
1513+
depwarn("""
1514+
`promote_eltype_op` is deprecated and should not be used.
1515+
See https://github.com/JuliaLang/julia/issues/19669.""",
1516+
:promote_eltype_op)
1517+
_promote_eltype_op(args...)
1518+
end
15071519

15081520
function unsafe_wrap(::Type{String}, p::Union{Ptr{UInt8},Ptr{Int8}}, len::Integer, own::Bool=false)
15091521
Base.depwarn("unsafe_wrap(String, ...) is deprecated; use `unsafe_string` instead.", :unsafe_wrap)

0 commit comments

Comments
 (0)