Skip to content

Commit 0b78f86

Browse files
author
José Valim
committed
Do not rely on compiled functions in Mix for autoload
Signed-off-by: José Valim <[email protected]>
1 parent 7180b98 commit 0b78f86

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

lib/mix/lib/mix/compilers/elixir.ex

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,29 +137,26 @@ defmodule Mix.Compilers.Elixir do
137137
|> List.delete(module)
138138
|> Enum.reject(&match?("elixir_" <> _, Atom.to_string(&1)))
139139

140-
attributes = module.__info__(:attributes)
141-
142-
kind = detect_kind(attributes)
140+
kind = detect_kind(module)
143141
source = Path.relative_to(source, cwd)
144-
files = get_external_resources(attributes, cwd)
142+
files = get_external_resources(module, cwd)
145143
tuple = {beam, module, kind, source, compile, runtime, files, binary}
146144
Agent.cast pid, &:lists.keystore(beam, 1, &1, tuple)
147145
end
148146

149-
defp detect_kind(attributes) do
147+
defp detect_kind(module) do
150148
cond do
151-
impl = attributes[:impl] ->
149+
impl = Module.get_attribute(module, :impl) ->
152150
{:impl, impl[:protocol]}
153-
attributes[:protocol] ->
151+
Module.get_attribute(module, :protocol) ->
154152
:protocol
155153
true ->
156154
:module
157155
end
158156
end
159157

160-
defp get_external_resources(attributes, cwd) do
161-
for {:external_resource, values} <- attributes,
162-
file <- values,
158+
defp get_external_resources(module, cwd) do
159+
for file <- Module.get_attribute(module, :external_resource),
163160
File.regular?(file),
164161
relative = Path.relative_to(file, cwd),
165162
Path.type(relative) == :relative,

0 commit comments

Comments
 (0)