File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -293,17 +293,17 @@ kws = keywords(f, first(methods(f)))
293
293
```
294
294
"""
295
295
function keywords (func, m:: Method )
296
- local table = methods (func). mt
296
+ table = methods (func). mt
297
297
# table is a MethodTable object. For some reason, the :kwsorter field is not always
298
298
# defined. An undefined kwsorter seems to imply that there are no methods in the
299
299
# MethodTable with keyword arguments.
300
300
if isdefined (table, :kwsorter )
301
301
# 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 )
303
303
if isa (kwargs, Vector) && length (kwargs) > 0
304
304
filter! (arg -> ! occursin (" #" , string (arg)), kwargs)
305
305
# 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)
307
307
if index != nothing
308
308
kwargs[index], kwargs[end ] = kwargs[end ], kwargs[index]
309
309
end
Original file line number Diff line number Diff line change 51
51
@test isa (m, Method)
52
52
# .. which should have a single keyword argument, :y
53
53
# 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 )
55
55
@test isa (kwargs, Vector{Any})
56
56
@test kwargs == [:y ]
57
57
# Base.kwarg_decl will return a Tuple{} for some reason when called on a method
58
58
# that does not have any arguments
59
59
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
61
65
end
62
66
@testset " format" begin
63
67
# Setup.
You can’t perform that action at this time.
0 commit comments