diff --git a/stdlib/REPL/src/REPLCompletions.jl b/stdlib/REPL/src/REPLCompletions.jl index 4986f604ae38f..a7aa4cbe570f7 100644 --- a/stdlib/REPL/src/REPLCompletions.jl +++ b/stdlib/REPL/src/REPLCompletions.jl @@ -1030,7 +1030,7 @@ function complete_keyword_argument(partial, last_idx, context_module) # take many seconds to run over the thousands of possible methods. Note that # isabstracttype would return naively return true for common constructor calls # like Array, but the REPL's introspection here may know their Type{T}. - isconcretetype(funct) || return fail + isconcretetype(funct) || (Base.isType(funct) && !isabstracttype(funct.parameters[1])) || return fail complete_methods!(methods, funct, Any[Vararg{Any}], kwargs_ex, -1, kwargs_flag == 1) # TODO: use args_ex instead of Any[Vararg{Any}] and only provide kwarg completion for # method calls compatible with the current arguments. diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index 5e6dddc455056..e714472a17bac 100644 --- a/stdlib/REPL/test/replcompletions.jl +++ b/stdlib/REPL/test/replcompletions.jl @@ -2330,3 +2330,31 @@ f54131 = F54131() @test_broken REPLCompletions.KeywordArgumentCompletion("kwarg") in a @test (@elapsed completions(s, lastindex(s), @__MODULE__, false)) < 1 end + +@kwdef struct T59244 + asdf = 1 + qwer = 2 +end +@kwdef struct S59244{T} + asdf::T = 1 + qwer::T = 2 +end +@testset "kwarg completion of types" begin + s = "T59244(as" + a, b, c = completions(s, lastindex(s), @__MODULE__, #= shift =# false) + @test REPLCompletions.KeywordArgumentCompletion("asdf") in a + + s = "T59244(; qw" + a, b, c = completions(s, lastindex(s), @__MODULE__, #= shift =# false) + @test REPLCompletions.KeywordArgumentCompletion("qwer") in a + @test REPLCompletions.KeywordArgumentCompletion("qwer") == only(a) + + s = "S59244(as" + a, b, c = completions(s, lastindex(s), @__MODULE__, #= shift =# false) + @test REPLCompletions.KeywordArgumentCompletion("asdf") in a + + s = "S59244(; qw" + a, b, c = completions(s, lastindex(s), @__MODULE__, #= shift =# false) + @test REPLCompletions.KeywordArgumentCompletion("qwer") in a + @test REPLCompletions.KeywordArgumentCompletion("qwer") == only(a) +end