Skip to content

Commit 3eb94a4

Browse files
committed
Make sure protocols are loaded before dispatching
Closes hexpm/hex#983.
1 parent 6eca976 commit 3eb94a4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/iex/lib/iex/helpers.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,10 @@ defmodule IEx.Helpers do
523523
:code.get_path()
524524
|> Protocol.extract_protocols()
525525
|> Enum.uniq()
526-
|> Enum.reject(fn protocol -> is_nil(protocol.impl_for(term)) end)
526+
|> Enum.filter(fn protocol ->
527+
Code.ensure_loaded?(protocol) and function_exported?(protocol, :impl_for, 1) and
528+
protocol.impl_for(term) != nil
529+
end)
527530
|> Enum.sort()
528531
|> Enum.map_join(", ", &inspect/1)
529532
end

0 commit comments

Comments
 (0)