Skip to content

Commit 5f50a1f

Browse files
committed
Ensure consolidated version of protocols is loaded
1 parent 8d645aa commit 5f50a1f

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

lib/elixir/lib/module/parallel_checker.ex

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ defmodule Module.ParallelChecker do
5252
# we discard their module map on purpose and start from file.
5353
info =
5454
if beam_location != [] and Keyword.has_key?(module_map.attributes, :__protocol__) do
55-
List.to_string(beam_location)
55+
{module, List.to_string(beam_location)}
5656
else
5757
cache_from_module_map(table, module_map)
5858
end
@@ -72,19 +72,25 @@ defmodule Module.ParallelChecker do
7272
Process.link(pid)
7373

7474
module_tuple =
75-
cond do
76-
is_tuple(info) ->
77-
info
78-
79-
is_binary(info) ->
80-
with {:ok, binary} <- File.read(info),
75+
case info do
76+
{module, location} ->
77+
location =
78+
case :code.which(module) do
79+
[_ | _] = path -> path
80+
_ -> location
81+
end
82+
83+
with {:ok, binary} <- File.read(location),
8184
{:ok, {_, [debug_info: chunk]}} <- :beam_lib.chunks(binary, [:debug_info]),
8285
{:debug_info_v1, backend, data} = chunk,
8386
{:ok, module_map} <- backend.debug_info(:elixir_v1, module, data, []) do
8487
cache_from_module_map(table, module_map)
8588
else
8689
_ -> nil
8790
end
91+
92+
_ ->
93+
info
8894
end
8995

9096
send(checker, {ref, :cached})
@@ -557,9 +563,7 @@ defmodule Module.ParallelChecker do
557563
end
558564

559565
def handle_call(:start, _from, %{modules: modules, protocols: protocols, table: table} = state) do
560-
for protocol <- protocols do
561-
:ets.delete(table, protocol)
562-
end
566+
:ets.insert(table, Enum.map(protocols, &{&1, :uncached}))
563567

564568
for {pid, ref} <- modules do
565569
send(pid, {ref, :cache})

lib/elixir/lib/protocol.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ defmodule Protocol do
688688
[] ->
689689
if Any in types do
690690
clauses = [{[Descr.term()], Descr.atom([Module.concat(protocol, Any)])}]
691-
{Descr.none(), clauses, clauses}
691+
{Descr.term(), clauses, clauses}
692692
else
693693
{Descr.none(), [{[Descr.term()], Descr.atom([nil])}],
694694
[{[Descr.none()], Descr.none()}]}

0 commit comments

Comments
 (0)