Skip to content

Commit 23c7974

Browse files
fix deprecated call, add test
1 parent 0ad323e commit 23c7974

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/forwarddiff.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ function (dec::DualEltypeChecker)(::Val{Y}) where {Y}
6363
anyeltypedual(getproperty(dec.x, Y), dec.counter)
6464
end
6565

66-
# use `getfield` for `Pairs`, see https://github.com/JuliaLang/julia/pull/39448
67-
function (dec::DualEltypeChecker{<:Base.Pairs})(::Val{Y}) where {Y}
68-
isdefined(dec.x, Y) || return Any
69-
anyeltypedual(getfield(dec.x, Y), dec.counter)
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
7072
end
7173

7274
# Untyped dispatch: catch composite types, check all of their fields

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)