Skip to content

Commit bc9b5ea

Browse files
author
José Valim
committed
Filter missing chunks instead of adding them
1 parent 992c240 commit bc9b5ea

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/elixir/lib/protocol.ex

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,16 @@ defmodule Protocol do
317317
[
318318
{:abstract_code, {_raw, abstract_code}},
319319
{:attributes, attributes},
320-
{:compile_info, compile_info},
321-
{'ExDc', docs},
322-
{'ExDp', deprecated}
320+
{:compile_info, compile_info} | extra_chunks
323321
] = entries
324322

323+
extra_chunks =
324+
for {name, contents} when is_binary(contents) <- extra_chunks,
325+
do: {List.to_string(name), contents}
326+
325327
case attributes[:protocol] do
326328
[fallback_to_any: any] ->
327-
{:ok, {protocol, any, abstract_code}, {compile_info, docs, deprecated}}
329+
{:ok, {protocol, any, abstract_code}, {compile_info, extra_chunks}}
328330

329331
_ ->
330332
{:error, :not_a_protocol}
@@ -493,15 +495,11 @@ defmodule Protocol do
493495
end
494496

495497
# Finally compile the module and emit its bytecode.
496-
defp compile(protocol, code, {compile_info, docs, deprecated}) do
498+
defp compile(protocol, code, {compile_info, extra_chunks}) do
497499
opts = Keyword.take(compile_info, [:source])
498500
opts = if Code.compiler_options()[:debug_info], do: [:debug_info | opts], else: opts
499501
{:ok, ^protocol, binary, _warnings} = :compile.forms(code, [:return | opts])
500-
501-
case docs do
502-
:missing_chunk -> {:ok, binary}
503-
_ -> {:ok, :elixir_erl.add_beam_chunks(binary, [{"ExDc", docs}, {"ExDp", deprecated}])}
504-
end
502+
{:ok, :elixir_erl.add_beam_chunks(binary, extra_chunks)}
505503
end
506504

507505
## Definition callbacks

0 commit comments

Comments
 (0)