Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions lib/elixir/lib/protocol.ex
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,14 @@ defmodule Protocol do
built_in_plus_any = [Any] ++ for {mod, _guard} <- built_in(), do: mod
structs = types -- built_in_plus_any

{select_impl, definitions} = List.keytake(definitions, {:__select_impl__, 1}, 0)
{dispatch_impl, definitions} = List.keytake(definitions, {:__dispatch_impl__, 4}, 0)
{select_struct, definitions} = List.keytake(definitions, {:__select_struct__, 1}, 0)
{select_impl, definitions} =
keytake_definition(definitions, {:__select_impl__, 1}, protocol)

{dispatch_impl, definitions} =
keytake_definition(definitions, {:__dispatch_impl__, 4}, protocol)

{select_struct, definitions} =
keytake_definition(definitions, {:__select_struct__, 1}, protocol)

protocol_funs = get_protocol_functions(protocol_def)

Expand Down Expand Up @@ -673,6 +678,22 @@ defmodule Protocol do
end
end

# The definitions below are generated by defprotocol. If any of them is
# missing, the beam was compiled with an incompatible version of Elixir.
defp keytake_definition(definitions, {name, arity}, protocol) do
case List.keytake(definitions, {name, arity}, 0) do
nil ->
raise ArgumentError,
"cannot consolidate protocol #{Macro.inspect_atom(:literal, protocol)}: " <>
"it does not define #{name}/#{arity}, which means it was compiled " <>
"with an incompatible version of Elixir, please recompile the protocol " <>
"with the current version"

{entry, definitions} ->
{entry, definitions}
end
end

defp new_signatures(definitions, protocol_funs, protocol, types, structs) do
alias Module.Types.Descr
types_minus_any = List.delete(types, Any)
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/lib/mix/compilers/elixir.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
defmodule Mix.Compilers.Elixir do
@moduledoc false

@manifest_vsn 37
@manifest_vsn 38
@checkpoint_vsn 5

import Record
Expand Down
Loading