Skip to content

Commit

Permalink
recovers generics of LineEdit.keymap while keeping specialization
Browse files Browse the repository at this point in the history
- `LineEdit.keymap` was annotated with concrete argument types to
prevent invalidations in JuliaLang#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`
  • Loading branch information
aviatesk committed Sep 6, 2020
1 parent 483b637 commit 99bd013
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 99bd013

Please sign in to comment.