Skip to content

Commit d522f96

Browse files
committed
List compile-time deps for after_verify
1 parent e281427 commit d522f96

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

lib/elixir/src/elixir_module.erl

+6-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ compile(Line, Module, Block, Vars, E) ->
131131

132132
RawCompileOpts = bag_lookup_element(DataBag, {accumulate, compile}, 2),
133133
CompileOpts = validate_compile_opts(RawCompileOpts, AllDefinitions, Unreachable, File, Line),
134+
134135
AfterVerify = bag_lookup_element(DataBag, {accumulate, after_verify}, 2),
136+
[elixir_env:trace({remote_function, [], VerifyMod, VerifyFun, 1}, E) ||
137+
{VerifyMod, VerifyFun} <- AfterVerify],
135138

136139
ModuleMap = #{
137140
struct => get_struct(DataSet),
@@ -159,7 +162,9 @@ compile(Line, Module, Block, Vars, E) ->
159162
elixir_env:trace({on_module, Binary, none}, E),
160163
warn_unused_attributes(File, DataSet, DataBag, PersistedAttributes),
161164
make_module_available(Module, Binary),
162-
(CheckerInfo == undefined) andalso eval_callbacks(Line, DataBag, after_verify, [Module], NE),
165+
(CheckerInfo == undefined) andalso
166+
[VerifyMod:VerifyFun(Module) ||
167+
{VerifyMod, VerifyFun} <- bag_lookup_element(DataBag, {accumulate, after_verify}, 2)],
163168
{module, Module, Binary, Result}
164169
catch
165170
error:undef:Stacktrace ->

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

+29
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,35 @@ defmodule Mix.Tasks.XrefTest do
268268
assert_trace("lib/b.ex", files, output)
269269
end
270270

271+
test "shows traces for module callbacks" do
272+
files = %{
273+
"lib/a.ex" => ~S"""
274+
defmodule A do
275+
@before_compile :"Elixir.B"
276+
@after_compile :"Elixir.B"
277+
@after_verify :"Elixir.B"
278+
end
279+
""",
280+
"lib/b.ex" => ~S"""
281+
defmodule B do
282+
defmacro __before_compile__(_env), do: :ok
283+
defmacro __after_compile__(_env, _binary), do: :ok
284+
def __after_verify__(_module), do: :ok
285+
end
286+
"""
287+
}
288+
289+
output = """
290+
Compiling 2 files (.ex)
291+
Generated sample app
292+
lib/a.ex:1: call B.__after_compile__/2 (compile)
293+
lib/a.ex:1: call B.__after_verify__/1 (compile)
294+
lib/a.ex:1: call B.__before_compile__/1 (compile)
295+
"""
296+
297+
assert_trace("lib/a.ex", files, output)
298+
end
299+
271300
test "filters per label" do
272301
files = %{
273302
"lib/a.ex" => ~S"""

0 commit comments

Comments
 (0)