diff --git a/base/REPLCompletions.jl b/base/REPLCompletions.jl index c056987ae25d9c..207be534a05203 100644 --- a/base/REPLCompletions.jl +++ b/base/REPLCompletions.jl @@ -323,10 +323,15 @@ function complete_methods(ex_org::Expr) out = String[] t_in = Tuple{Core.Typeof(func), args_ex...} # Input types na = length(args_ex)+1 - for method in methods(func) + ml = methods(func) + kwtype = isdefined(ml.mt, :kwsorter) ? Nullable{DataType}(typeof(ml.mt.kwsorter)) : Nullable{DataType}() + io = IOBuffer() + for method in ml # Check if the method's type signature intersects the input types - typeintersect(Tuple{method.sig.parameters[1 : min(na, end)]...}, t_in) != Union{} && - push!(out,string(method)) + if typeintersect(Tuple{method.sig.parameters[1 : min(na, end)]...}, t_in) != Union{} + show(io, method, kwtype=kwtype) + push!(out, takebuf_string(io)) + end end return out end diff --git a/test/replcompletions.jl b/test/replcompletions.jl index f7d9d88531b7fa..0bc56bb4cc11b3 100644 --- a/test/replcompletions.jl +++ b/test/replcompletions.jl @@ -43,6 +43,8 @@ module CompletionFoo const a=x->x test6()=[a, a] + kwtest(; x=1, y=2, w...) = pass + array = [1, 1] varfloat = 0.1 @@ -325,6 +327,12 @@ c, r, res = test_complete(s) @test length(c) == 2 ################################################################# +s = "CompletionFoo.kwtest( " +c, r, res = test_complete(s) +@test !res +@test length(c) == 1 +@test contains(c[1], "x, y, w...") + # Test of inference based getfield completion s = "\"\"." c,r = test_complete(s)