Skip to content

Commit cca3e8c

Browse files
authored
Merge pull request #296 from jishnub/nameof
Use nameof instead of Type.name.name
2 parents 4070229 + 5c598b0 commit cca3e8c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/serialization.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ function JSON.lower(x::Union{values(SUPPORTED_TYPES)...})
1414
name = String(fieldname(T, i))
1515
field = getfield(x, i)
1616
ft = typeof(field)
17-
value = ft <: get(SUPPORTED_TYPES, ft.name.name, Union{}) ? JSON.lower(field) : field
17+
value = ft <: get(SUPPORTED_TYPES, nameof(ft), Union{}) ? JSON.lower(field) : field
1818
d[name] = value
1919
end
20-
[string(typeof(x).name.name), d]
20+
[string(nameof(typeof(x))), d]
2121
end
2222

2323
# a minimal 'eval' function, mirroring KeyTypes, but being slightly more lenient
@@ -40,7 +40,7 @@ function recover(x::Vector)
4040
for i = 1:fc
4141
ft = fieldtype(T, i)
4242
fn = String(fieldname(T, i))
43-
if ft <: get(SUPPORTED_TYPES, ft.name.name, Union{})
43+
if ft <: get(SUPPORTED_TYPES, nameof(ft), Union{})
4444
xsi = recover(fields[fn])
4545
else
4646
xsi = convert(ft, fields[fn])
@@ -95,7 +95,7 @@ function save(io::IO, args...)
9595
"The name will be ignored and the object will be serialized " *
9696
"in the order it appears in the input.")
9797
continue
98-
elseif !(arg isa get(SUPPORTED_TYPES, typeof(arg).name.name, Union{}))
98+
elseif !(arg isa get(SUPPORTED_TYPES, nameof(typeof(arg)), Union{}))
9999
throw(ArgumentError("Only BenchmarkTools types can be serialized."))
100100
end
101101
push!(goodargs, arg)

0 commit comments

Comments
 (0)