Skip to content

Commit 21f7660

Browse files
dict value fix (#688)
* dict value fix * Update test/tracing.jl Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 234d168 commit 21f7660

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/Tracing.jl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,19 @@ end
164164
Base.@nospecializeinfer @inline dict_key(::Type{<:AbstractDict}) = nothing
165165
Base.@nospecializeinfer @inline dict_key(::Type{<:AbstractDict{K}}) where {K} = K
166166
Base.@nospecializeinfer @inline dict_value(::Type{<:AbstractDict}) = nothing
167-
Base.@nospecializeinfer @inline dict_value(
168-
::Type{<:(AbstractDict{K,V} where {K})}
169-
) where {V} = V
167+
Base.@nospecializeinfer @inline function dict_value(
168+
T::Type{<:(AbstractDict{K,V} where {K})}
169+
) where {V}
170+
if @isdefined(V)
171+
V
172+
elseif T <: UnionAll
173+
dict_value(T.body)
174+
elseif T <: Dict && length(T.parameters) >= 2
175+
T.parameters[2]
176+
else
177+
error("Could not get element type of $T")
178+
end
179+
end
170180

171181
Base.@nospecializeinfer function traced_type_inner(
172182
@nospecialize(T::Type{<:AbstractDict}),

test/tracing.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,23 @@ end
138138
(Dict{A,TracedRArray{Float64,0}} where {A}),
139139
(Dict{A,TracedRArray{Float64,0}} where {A}),
140140
),
141+
(
142+
(
143+
Dict{
144+
Symbol,NTuple{nsteps,SpectralVariable3D}
145+
} where {nsteps} where {SpectralVariable3D}
146+
),
147+
(
148+
Dict{
149+
Symbol,NTuple{nsteps,SpectralVariable3D}
150+
} where {nsteps} where {SpectralVariable3D}
151+
),
152+
(
153+
Dict{
154+
Symbol,NTuple{nsteps,SpectralVariable3D}
155+
} where {nsteps} where {SpectralVariable3D}
156+
),
157+
),
141158
(
142159
Base.Pairs{Symbol,Union{}},
143160
Base.Pairs{Symbol,Union{}},

0 commit comments

Comments
 (0)