@@ -1082,12 +1082,15 @@ function complete_keyword_argument(partial::String, last_idx::Int, context_modul
10821082 kwargs_flag == 2 && return fail # one of the previous kwargs is invalid
10831083
10841084 methods = Completion[]
1085- # limit the number of methods to prevent performance issues while allowing
1086- # completions for nearly all common functions. This is distinct from the other
1087- # uses of MAX_METHOD_COMPLETIONS, which primarily used to limit the number
1088- # of methods to _display_ before showing an alternative message; here we're
1089- # searching a larger number to find a subset that contains matching kwargs
1090- complete_methods! (methods, funct, Any[Vararg{Any}], kwargs_ex, shift ? - 1 : 500 , kwargs_flag == 1 )
1085+ # Limit kwarg completions to cases when function is concretely known; looking up
1086+ # matching methods for abstract functions — particularly `Any` or `Function` — can
1087+ # take many seconds to run over the thousands of possible methods. Note that
1088+ # isabstracttype would return naively return true for common constructor calls
1089+ # like Array, but the REPL's introspection here may know their Type{T}.
1090+ isabstract (f) = isabstracttype (f)
1091+ isabstract (:: Type{Type{T}} ) where {T} = isabstracttype (T)
1092+ isabstract (funct) && return fail
1093+ complete_methods! (methods, funct, Any[Vararg{Any}], kwargs_ex, - 1 , kwargs_flag == 1 )
10911094 # TODO : use args_ex instead of Any[Vararg{Any}] and only provide kwarg completion for
10921095 # method calls compatible with the current arguments.
10931096
0 commit comments