diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 6cbdd4a8c56fc..1a92a065756d9 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -1790,12 +1790,6 @@ function mapslices(f, A::AbstractArray, dims::AbstractVector) return R end -# These are needed because map(eltype, As) is not inferrable -promote_eltype_op(::Any) = Any -promote_eltype_op(op, A) = (@_inline_meta; promote_op(op, eltype(A))) -promote_eltype_op(op, A, B) = (@_inline_meta; promote_op(op, eltype(A), eltype(B))) -promote_eltype_op(op, A, B, C, D...) = (@_inline_meta; promote_eltype_op(op, eltype(A), promote_eltype_op(op, B, C, D...))) - ## 1 argument function map!{F}(f::F, dest::AbstractArray, A::AbstractArray) diff --git a/base/broadcast.jl b/base/broadcast.jl index 1d2c3bacb02e7..f963a2ebc5d30 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -3,7 +3,7 @@ module Broadcast using Base.Cartesian -using Base: promote_eltype_op, linearindices, tail, OneTo, to_shape, +using Base: linearindices, tail, OneTo, to_shape, _msk_end, unsafe_bitgetindex, bitcache_chunks, bitcache_size, dumpbitcache, nullable_returntype, null_safe_eltype_op, hasvalue import Base: broadcast, broadcast! @@ -267,11 +267,6 @@ function broadcast_t(f, ::Type{Bool}, shape, iter, As...) return B end -# broadcast method that uses inference to find the type, but preserves abstract -# container types when possible (used by binary elementwise operators) -@inline broadcast_elwise_op(f, As...) = - broadcast!(f, similar(Array{promote_eltype_op(f, As...)}, broadcast_indices(As...)), As...) - eltypestuple(a) = (Base.@_pure_meta; Tuple{eltype(a)}) eltypestuple(T::Type) = (Base.@_pure_meta; Tuple{Type{T}}) eltypestuple(a, b...) = (Base.@_pure_meta; Tuple{eltypestuple(a).types..., eltypestuple(b...).types...}) diff --git a/base/deprecated.jl b/base/deprecated.jl index 41020dcb5fc62..f8f21f489f57b 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1239,7 +1239,7 @@ for (Bsig, A1sig, A2sig, gbb, funcname) in end # let broadcast_cache end _broadcast_zpreserving!(args...) = broadcast!(args...) -_broadcast_zpreserving(args...) = Base.Broadcast.broadcast_elwise_op(args...) +_broadcast_zpreserving(f, As...) = broadcast!(f, similar(Array{promote_op(f, map(eltype, As)...)}, Base.Broadcast.broadcast_indices(As...)), As...) _broadcast_zpreserving{Tv1,Ti1,Tv2,Ti2}(f::Function, A_1::SparseMatrixCSC{Tv1,Ti1}, A_2::SparseMatrixCSC{Tv2,Ti2}) = _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) _broadcast_zpreserving{Tv,Ti}(f::Function, A_1::SparseMatrixCSC{Tv,Ti}, A_2::Union{Array,BitArray,Number}) = @@ -1470,4 +1470,7 @@ end @deprecate (|)(A::AbstractArray, b::Number) A .| b @deprecate (|)(A::AbstractArray, B::AbstractArray) A .| B +# Calling promote_op is likely a bad idea, so deprecate its convenience wrapper promote_eltype_op +@deprecate promote_eltype_op(op, As...) promote_op(op, map(eltype, As)...) + # End deprecations scheduled for 0.6