From 99bd01352c15f16a808a9f0116f381f74bfbf21b Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Sun, 6 Sep 2020 14:17:34 +0900 Subject: [PATCH] recovers generics of `LineEdit.keymap` while keeping specialization - `LineEdit.keymap` was annotated with concrete argument types to prevent invalidations in #37163 - but it loses generics of this function, which in turn makes OhMyREPL.jl errors on its initialization with `NoMethodError` on master * especially [this line](https://github.com/KristofferC/OhMyREPL.jl/blob/cc7e467606e1cc13f11f95576d1a12c371cd4214/src/repl.jl#L284) can't be matched to `Union{Vector{AnyDict}, Vector{Dict{Char,Any}}}` * no sure why but `LineEdit.keymap(Base.AnyDict[NEW_KEYBINDINGS, main_mode.keymap_dict])` doesn't help the matching; the error seems to say `Base.AnyDict[NEW_KEYBINDINGS, main_mode.keymap_dict]` is somehow widened to `Vector{Dict}`: ``` MethodError: no method matching keymap(::Vector{Dict}) Closest candidates are: keymap(::Any, ::Union{REPL.LineEdit.HistoryPrompt, REPL.LineEdit.PrefixHistoryPrompt}) at /Users/aviatesk/julia/julia/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2007 keymap(::Union{Vector{Dict{Any, Any}}, Vector{Dict{Char, Any}}}) at /Users/aviatesk/julia/julia/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:1610 keymap(::REPL.LineEdit.PromptState, ::REPL.LineEdit.Prompt) at /Users/aviatesk/julia/julia/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2505 ... ``` - I think it's better to keep the generics anyway, so this PR widens function while keeping specialization by annotating `at-specialize` --- stdlib/REPL/src/LineEdit.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/REPL/src/LineEdit.jl b/stdlib/REPL/src/LineEdit.jl index 64104ac6caca4..e791d913eff40 100644 --- a/stdlib/REPL/src/LineEdit.jl +++ b/stdlib/REPL/src/LineEdit.jl @@ -1607,7 +1607,7 @@ function validate_keymap(keymap) end end -function keymap(keymaps::Union{Vector{AnyDict},Vector{Dict{Char,Any}}}) +function keymap(@specialize(keymaps::AbstractVector{<:AbstractDict})) # keymaps is a vector of prioritized keymaps, with highest priority first ret = keymap_unify(map(normalize_keys, reverse(keymaps))) validate_keymap(ret)