Skip to content

Commit 0ae31ae

Browse files
author
Miha Zgubic
committed
deprecate convert
1 parent e047fd8 commit 0ae31ae

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/deprecated.jl

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,19 @@ for T in (:Thunk, :InplaceableThunk)
5656
end
5757

5858

59-
Base.@deprecate InplaceableThunk(t::Thunk, add!) InplaceableThunk(add!, t)
59+
Base.@deprecate InplaceableThunk(t::Thunk, add!) InplaceableThunk(add!, t)
60+
61+
const CONVERT_DEPRECATION = "convert(::Type{T}, t::Tangent) is deprecated, use ChainRulesCore.backing(t) instead"
62+
63+
function Base.convert(::Type{<:NamedTuple}, comp::Tangent{<:Any, <:NamedTuple})
64+
Base.depwarn(CONVERT_DEPRECATION, :convert)
65+
return backing(comp)
66+
end
67+
function Base.convert(::Type{<:Tuple}, comp::Tangent{<:Any, <:Tuple})
68+
Base.depwarn(CONVERT_DEPRECATION, :convert)
69+
return backing(comp)
70+
end
71+
function Base.convert(::Type{<:Dict}, comp::Tangent{<:Dict, <:Dict})
72+
Base.depwarn(CONVERT_DEPRECATION, :convert)
73+
return backing(comp)
74+
end

src/differentials/composite.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ function Base.show(io::IO, comp::Tangent{P}) where P
6868
end
6969
end
7070

71-
Base.convert(::Type{<:NamedTuple}, comp::Tangent{<:Any, <:NamedTuple}) = backing(comp)
72-
Base.convert(::Type{<:Tuple}, comp::Tangent{<:Any, <:Tuple}) = backing(comp)
73-
Base.convert(::Type{<:Dict}, comp::Tangent{<:Dict, <:Dict}) = backing(comp)
74-
7571
Base.getindex(comp::Tangent, idx) = getindex(backing(comp), idx)
7672

7773
# for Tuple

0 commit comments

Comments
 (0)