Skip to content

Commit 949ac2b

Browse files
author
José Valim
committed
Tolerate modules that do not export :deprecated info, closes #7182
1 parent adb1fa1 commit 949ac2b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/mix/lib/mix/tasks/xref.ex

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ defmodule Mix.Tasks.Xref do
332332
# If the module is loaded, we will use the faster function_exported?/3
333333
# check for exports and __info__/1 for deprecated
334334
if function_exported?(module, :__info__, 1) do
335-
{module, module.__info__(:deprecated)}
335+
{module, load_deprecated_from_module(module)}
336336
else
337337
{module, []}
338338
end
@@ -341,14 +341,14 @@ defmodule Mix.Tasks.Xref do
341341
with [_ | _] = file <- :code.which(module),
342342
{:ok, {^module, [{:exports, exports}, {'ExDp', deprecated}]}} <-
343343
:beam_lib.chunks(file, [:exports, 'ExDp'], [:allow_missing_chunks]) do
344-
{exports, load_deprecated(deprecated)}
344+
{exports, load_deprecated_from_chunk(deprecated)}
345345
else
346346
_ -> {:unknown_module, []}
347347
end
348348
end
349349
end
350350

351-
defp load_deprecated(chunk) do
351+
defp load_deprecated_from_chunk(chunk) do
352352
if is_binary(chunk) do
353353
{:elixir_deprecated_v1, deprecated} = :erlang.binary_to_term(chunk)
354354
deprecated
@@ -357,6 +357,14 @@ defmodule Mix.Tasks.Xref do
357357
end
358358
end
359359

360+
defp load_deprecated_from_module(module) do
361+
try do
362+
module.__info__(:deprecated)
363+
rescue
364+
_ -> []
365+
end
366+
end
367+
360368
defp unreachable_mfa(exports, module, func, arity) do
361369
cond do
362370
skip_unreachable?(module, func, arity) ->

0 commit comments

Comments
 (0)