Skip to content

Commit f42d21a

Browse files
committed
using Tricks.compat_hasmethod
1 parent dfc8493 commit f42d21a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PrettyTables = "0.8, 0.9"
1717
Reexport = "^0.2.0"
1818
Tables = "0.2, 1.0"
1919
TypeTransform = "0.1.3"
20+
Tricks = "0.1.3"
2021
julia = "1.2"
2122

2223
[extras]

src/xmlutils/nodeparse.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Tricks: static_hasmethod
2-
# TODO use traits for static_hasmethod checks
1+
using Tricks: compat_hasmethod
2+
# TODO use traits for compat_hasmethod checks
33

44
# Scalar parsers
55

@@ -18,9 +18,9 @@ function nodeparse(type::Type, content::String)
1818
# https://julialang.slack.com/archives/C6A044SQH/p1578442480438100
1919
if hasmethod(type, Tuple{String}) && Core.Compiler.return_type(type, Tuple{Node})=== Union{}
2020
return type(content)
21-
elseif static_hasmethod(convert, Tuple{String, type})
21+
elseif compat_hasmethod(convert, Tuple{String, type})
2222
return convert(type, content)
23-
elseif static_hasmethod(parse, Tuple{type, String})
23+
elseif compat_hasmethod(parse, Tuple{type, String})
2424
return parse(type, content)
2525
else
2626
error("Could not parse a String as type $type")
@@ -33,9 +33,9 @@ function nodeparse(type::Type, elm::Node)
3333
content = elm.content
3434
if hasmethod(type, Tuple{String}) && Core.Compiler.return_type(type, Tuple{Node})=== Union{}
3535
return type(content)
36-
elseif static_hasmethod(convert, Tuple{String, type})
36+
elseif compat_hasmethod(convert, Tuple{String, type})
3737
return convert(type, content)
38-
elseif static_hasmethod(parse, Tuple{type, String})
38+
elseif compat_hasmethod(parse, Tuple{type, String})
3939
return parse(type, content)
4040
else
4141
# should be the last to avoid invoking generic methods
@@ -65,12 +65,12 @@ function nodeparse(::Type{T}, contents::Vector{String}) where {T}
6565
elms_typed[i] = type(content)
6666
i+=1
6767
end
68-
elseif static_hasmethod(convert, Tuple{String, type})
68+
elseif compat_hasmethod(convert, Tuple{String, type})
6969
for content in contents
7070
elms_typed[i] = convert(type, content)
7171
i+=1
7272
end
73-
elseif static_hasmethod(parse, Tuple{type, String})
73+
elseif compat_hasmethod(parse, Tuple{type, String})
7474
for content in contents
7575
elms_typed[i] = parse(type, content)
7676
i+=1
@@ -90,12 +90,12 @@ function nodeparse(type::Type{T}, elms::Vector{Node}) where {T}
9090
elms_typed[i] = type(elm.content)
9191
i+=1
9292
end
93-
elseif static_hasmethod(convert, Tuple{String, type})
93+
elseif compat_hasmethod(convert, Tuple{String, type})
9494
for elm in elms
9595
elms_typed[i] = convert(type, elm.content)
9696
i+=1
9797
end
98-
elseif static_hasmethod(parse, Tuple{type, String})
98+
elseif compat_hasmethod(parse, Tuple{type, String})
9999
for elm in elms
100100
elms_typed[i] = parse(type, elm.content)
101101
i+=1

0 commit comments

Comments
 (0)