Skip to content

Commit 12a4462

Browse files
Merge pull request #819 from thevolatilebit/patch-deprecate
fix deprecated call
2 parents a882fd9 + 23c7974 commit 12a4462

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/forwarddiff.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,20 @@ struct DualEltypeChecker{T}
5757
counter::Int
5858
DualEltypeChecker(x::T, counter::Int) where {T} = new{T}(x, counter + 1)
5959
end
60+
6061
function (dec::DualEltypeChecker)(::Val{Y}) where {Y}
6162
isdefined(dec.x, Y) || return Any
6263
anyeltypedual(getproperty(dec.x, Y), dec.counter)
6364
end
6465

66+
# use `getfield` on `Pairs`, see https://github.com/JuliaLang/julia/pull/39448
67+
if VERSION >= v"1.7"
68+
function (dec::DualEltypeChecker{<:Base.Pairs})(::Val{Y}) where {Y}
69+
isdefined(dec.x, Y) || return Any
70+
anyeltypedual(getfield(dec.x, Y), dec.counter)
71+
end
72+
end
73+
6574
# Untyped dispatch: catch composite types, check all of their fields
6675
"""
6776
anyeltypedual(x)

test/forwarddiff_dual_detection.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,7 @@ for p in p_possibilities_configs_not_inferred
222222
u0 = ForwardDiff.Dual(2.0)
223223
@test DiffEqBase.promote_u0(u0, p, t0) isa ForwardDiff.Dual
224224
end
225+
226+
# use `getfield` on `Pairs`, see https://github.com/JuliaLang/julia/pull/39448
227+
VERSION >= v"1.7" &&
228+
@test_nowarn DiffEqBase.DualEltypeChecker(pairs((;)), 0)(Val(:data))

0 commit comments

Comments
 (0)