Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/base/broadcast.jl b/base/broadcast.jl
index 95a25bed66..7c0fa71aba 100644
--- a/base/broadcast.jl
+++ b/base/broadcast.jl
@@ -97,9 +97,13 @@ struct DefaultArrayStyle{N} <: AbstractArrayStyle{N} end
(::Type{<:DefaultArrayStyle})(::Val{N}) where N = DefaultArrayStyle{N}()
const DefaultVectorStyle = DefaultArrayStyle{1}
const DefaultMatrixStyle = DefaultArrayStyle{2}
-BroadcastStyle(::AbstractArray{T,N}) where {T,N} = DefaultArrayStyle{N}()
+BroadcastStyle(v::AbstractArray{T,N}) where {T,N} = _broadcast_api_deprecation(DefaultArrayStyle{N}(), BroadcastStyle(typeof(v)))
BroadcastStyle(::Ref) = DefaultArrayStyle{0}()
-BroadcastStyle(v::Any) = DefaultArrayStyle{ndims(v)}()
+BroadcastStyle(v::Any) = _broadcast_api_deprecation(DefaultArrayStyle{ndims(v)}(), BroadcastStyle(typeof(v)))
+## TODO: DELETE AFTER 0.7 deprecations are removed
+_broadcast_api_deprecation(s::DefaultArrayStyle, ::DefaultArrayStyle) = s
+BroadcastStyle(::Type{T}) where T = DefaultArrayStyle{ndims(T)}()
+## END TODO
# `ArrayConflict` is an internal type signaling that two or more different `AbstractArrayStyle`
# objects were supplied as arguments, and that no rule was defined for resolving the
diff --git a/base/deprecated.jl b/base/deprecated.jl
index 8efe89cbe3..55bb511fc4 100644
--- a/base/deprecated.jl
+++ b/base/deprecated.jl
@@ -812,6 +812,14 @@ finalizer(f::Ptr{Cvoid}, o::Function) = invoke(finalizer, Tuple{Ptr{Cvoid}, Any}
Base.@deprecate_binding broadcast_t broadcast false ", `broadcast_t(f, ::Type{ElType}, shape, iter, As...)` should become `broadcast(f, Broadcast.DefaultArrayStyle{N}(), ElType, shape, As...))` (see the manual chapter Interfaces)"
end
+# Internal broadcast extension stepping-stone for implementors of a prior 0.7 API
+@eval Broadcast begin
+ @noinline function _broadcast_api_deprecation(::DefaultArrayStyle, s)
+ Base.depwarn("the BroadcastStyle API is changing. The implementation of $s should work on values, not types.", :_broadcast_api_deprecation)
+ s
+ end
+ # TODO: also remove the _broadcast_api_deprecation redirection in base/broadcast.jl around line 102
+end
### deprecations for lazier, less jazzy linalg transition in the next several blocks ###
# TODOs re. .' deprecation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.