Skip to content

Commit 562699a

Browse files
authored
Merge branch 'release-1.11' into backports-release-1.11
2 parents 9aa9ec6 + 9615af0 commit 562699a

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.11.5
1+
1.11.6

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,13 @@ function complete_keyword_argument(partial, last_idx, context_module)
10251025
kwargs_flag == 2 && return fail # one of the previous kwargs is invalid
10261026

10271027
methods = Completion[]
1028-
complete_methods!(methods, funct, Any[Vararg{Any}], kwargs_ex, MAX_METHOD_COMPLETIONS, kwargs_flag == 1)
1028+
# Limit kwarg completions to cases when function is concretely known; looking up
1029+
# matching methods for abstract functions — particularly `Any` or `Function` — can
1030+
# take many seconds to run over the thousands of possible methods. Note that
1031+
# isabstracttype would return naively return true for common constructor calls
1032+
# like Array, but the REPL's introspection here may know their Type{T}.
1033+
isconcretetype(funct) || return fail
1034+
complete_methods!(methods, funct, Any[Vararg{Any}], kwargs_ex, -1, kwargs_flag == 1)
10291035
# TODO: use args_ex instead of Any[Vararg{Any}] and only provide kwarg completion for
10301036
# method calls compatible with the current arguments.
10311037

stdlib/REPL/test/replcompletions.jl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2301,3 +2301,32 @@ let s = "Issue53126()."
23012301
@test res
23022302
@test isempty(c)
23032303
end
2304+
2305+
function g54131 end
2306+
for i in 1:498
2307+
@eval g54131(::Val{$i}) = i
2308+
end
2309+
g54131(::Val{499}; kwarg=true) = 499*kwarg
2310+
struct F54131; end
2311+
Base.getproperty(::F54131, ::Symbol) = Any[cos, sin, g54131][rand(1:3)]
2312+
f54131 = F54131()
2313+
@testset "performance of kwarg completion with large method tables" begin
2314+
# The goal here is to simply ensure we aren't hitting catestrophically bad
2315+
# behaviors when shift isn't pressed. The difference between good and bad
2316+
# is on the order of tens of milliseconds vs tens of seconds; using 1 sec as
2317+
# a very rough canary that is hopefully robust even in the noisy CI coalmines
2318+
s = "g54131(kwa"
2319+
a, b, c = completions(s, lastindex(s), @__MODULE__, #= shift =# false)
2320+
@test REPLCompletions.KeywordArgumentCompletion("kwarg") in a
2321+
@test (@elapsed completions(s, lastindex(s), @__MODULE__, false)) < 1
2322+
2323+
s = "f54131.x("
2324+
a, b, c = completions(s, lastindex(s), @__MODULE__, false)
2325+
@test only(a) isa REPLCompletions.TextCompletion
2326+
@test (@elapsed completions(s, lastindex(s), @__MODULE__, false)) < 1
2327+
2328+
s = "f54131.x(kwa"
2329+
a, b, c = completions(s, lastindex(s), @__MODULE__, false)
2330+
@test_broken REPLCompletions.KeywordArgumentCompletion("kwarg") in a
2331+
@test (@elapsed completions(s, lastindex(s), @__MODULE__, false)) < 1
2332+
end

0 commit comments

Comments
 (0)