Skip to content

Commit fa519c8

Browse files
committed
Fix call to internal function kwarg_decl for Julia 1.4, fixes #82.
1 parent 3f45789 commit fa519c8

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/utilities.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,17 +293,17 @@ kws = keywords(f, first(methods(f)))
293293
```
294294
"""
295295
function keywords(func, m::Method)
296-
local table = methods(func).mt
296+
table = methods(func).mt
297297
# table is a MethodTable object. For some reason, the :kwsorter field is not always
298298
# defined. An undefined kwsorter seems to imply that there are no methods in the
299299
# MethodTable with keyword arguments.
300300
if isdefined(table, :kwsorter)
301301
# Fetching method keywords stolen from base/replutil.jl:572-576 (commit 3b45cdc9aab0):
302-
local kwargs = Base.kwarg_decl(m, typeof(table.kwsorter))
302+
kwargs = VERSION < v"1.4.0-DEV.215" ? Base.kwarg_decl(m, typeof(table.kwsorter)) : Base.kwarg_decl(m)
303303
if isa(kwargs, Vector) && length(kwargs) > 0
304304
filter!(arg -> !occursin("#", string(arg)), kwargs)
305305
# Keywords *may* not be sorted correctly. We move the vararg one to the end.
306-
local index = findfirst(arg -> endswith(string(arg), "..."), kwargs)
306+
index = findfirst(arg -> endswith(string(arg), "..."), kwargs)
307307
if index != nothing
308308
kwargs[index], kwargs[end] = kwargs[end], kwargs[index]
309309
end

test/tests.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,17 @@ end
5151
@test isa(m, Method)
5252
# .. which should have a single keyword argument, :y
5353
# Base.kwarg_decl returns a Vector{Any} of the keyword arguments.
54-
local kwargs = Base.kwarg_decl(m, typeof(mt.kwsorter))
54+
local kwargs = VERSION < v"1.4.0-DEV.215" ? Base.kwarg_decl(m, typeof(mt.kwsorter)) : Base.kwarg_decl(m)
5555
@test isa(kwargs, Vector{Any})
5656
@test kwargs == [:y]
5757
# Base.kwarg_decl will return a Tuple{} for some reason when called on a method
5858
# that does not have any arguments
5959
m = which(M.j_1, (Any,Any)) # fetch the no-keyword method
60-
@test Base.kwarg_decl(m, typeof(methods(M.j_1).mt.kwsorter)) == Tuple{}()
60+
if VERSION < v"1.4.0-DEV.215"
61+
@test Base.kwarg_decl(m, typeof(methods(M.j_1).mt.kwsorter)) == Tuple{}()
62+
else
63+
@test Base.kwarg_decl(m) == []
64+
end
6165
end
6266
@testset "format" begin
6367
# Setup.

0 commit comments

Comments
 (0)