Skip to content

Commit 8a22621

Browse files
author
José Valim
committed
Always include the compiled file source in manifests
See dashbitco/nimble_csv#4. Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
1 parent a9559ef commit 8a22621

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

lib/elixir/lib/kernel/parallel_compiler.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ defmodule Kernel.ParallelCompiler do
107107
:erlang.spawn_monitor fn ->
108108
# Set the elixir_compiler_pid used by our custom Kernel.ErrorHandler.
109109
:erlang.put(:elixir_compiler_pid, parent)
110+
:erlang.put(:elixir_compiler_file, file)
110111
:erlang.process_flag(:error_handler, Kernel.ErrorHandler)
111112

112113
exit(try do

lib/elixir/lib/kernel/parallel_require.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,21 +47,22 @@ defmodule Kernel.ParallelRequire do
4747
wait_for_messages(files, waiting, callbacks, schedulers, result)
4848
end
4949

50-
defp spawn_requires([h | t], waiting, callbacks, schedulers, result) do
50+
defp spawn_requires([file | files], waiting, callbacks, schedulers, result) do
5151
parent = self()
5252
{pid, ref} = :erlang.spawn_monitor fn ->
5353
:erlang.put(:elixir_compiler_pid, parent)
54+
:erlang.put(:elixir_compiler_file, file)
5455

5556
exit(try do
56-
new = Code.require_file(h) || []
57-
{:required, Enum.map(new, &elem(&1, 0)), h}
57+
new = Code.require_file(file) || []
58+
{:required, Enum.map(new, &elem(&1, 0)), file}
5859
catch
5960
kind, reason ->
6061
{:failure, kind, reason, System.stacktrace}
6162
end)
6263
end
6364

64-
spawn_requires(t, [{pid, ref} | waiting], callbacks, schedulers, result)
65+
spawn_requires(files, [{pid, ref} | waiting], callbacks, schedulers, result)
6566
end
6667

6768
defp wait_for_messages(files, waiting, callbacks, schedulers, result) do

lib/elixir/src/elixir_module.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ load_form(Line, Data, Forms, Opts, E) ->
378378
ok;
379379
PID ->
380380
Ref = make_ref(),
381-
PID ! {module_available, self(), Ref, ?m(E, file), Module, Binary},
381+
PID ! {module_available, self(), Ref, get(elixir_compiler_file), Module, Binary},
382382
receive {Ref, ack} -> ok end
383383
end;
384384
_ ->

lib/mix/test/mix/tasks/xref_test.exs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,32 @@ defmodule Mix.Tasks.XrefTest do
564564
end
565565
end
566566

567+
test "graph: with dynamic module" do
568+
in_fixture "no_mixfile", fn ->
569+
File.write! "lib/a.ex", """
570+
B.define()
571+
"""
572+
573+
File.write! "lib/b.ex", """
574+
defmodule B do
575+
def define do
576+
defmodule A do
577+
end
578+
end
579+
end
580+
"""
581+
582+
assert Mix.Task.run("xref", ["graph"]) == :ok
583+
584+
assert """
585+
Compiling 2 files (.ex)
586+
Generated sample app
587+
lib/a.ex
588+
lib/b.ex
589+
""" = receive_until_no_messages([])
590+
end
591+
end
592+
567593
defp assert_graph(opts \\ [], dot \\ false, expected) do
568594
in_fixture "no_mixfile", fn ->
569595
File.write! "lib/a.ex", """

0 commit comments

Comments
 (0)