Skip to content

Commit d59c801

Browse files
josevalimJosé Valim
authored andcommitted
Support specsdiff __info__ spec clauses, closes #7460 (#7461)
Signed-off-by: José Valim <[email protected]>
1 parent c107a2f commit d59c801

File tree

2 files changed

+50
-21
lines changed

2 files changed

+50
-21
lines changed

lib/elixir/src/elixir_erl.erl

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -293,29 +293,43 @@ add_info_function(Line, Module, Def, Defmacro, Deprecated) ->
293293
AllowedArgs = lists:map(fun(Atom) -> {atom, Line, Atom} end, AllowedAttrs),
294294

295295
Spec =
296-
{attribute, Line, spec, {{'__info__', 1},
297-
[{type, Line, 'fun', [
298-
{type, Line, product, [
299-
{type, Line, union, AllowedArgs}
300-
]},
301-
{type, Line, union, [
302-
{type, Line, atom, []},
303-
{type, Line, list, [
296+
%% TODO: Remove this check once we depend only on 20
297+
case erlang:system_info(otp_release) of
298+
"19" ->
299+
{attribute, Line, spec, {{'__info__', 1},
300+
[{type, Line, 'fun', [
301+
{type, Line, product, [
302+
{type, Line, union, AllowedArgs}
303+
]},
304304
{type, Line, union, [
305-
{type, Line, tuple, [
306-
{type, Line, atom, []},
307-
{type, Line, any, []}
308-
]},
309-
{type, Line, tuple, [
310-
{type, Line, atom, []},
311-
{type, Line, byte, []},
312-
{type, Line, integer, []}
305+
{type, Line, atom, []},
306+
{type, Line, list, [
307+
{type, Line, union, [
308+
{type, Line, tuple, [
309+
{type, Line, atom, []},
310+
{type, Line, any, []}
311+
]},
312+
{type, Line, tuple, [
313+
{type, Line, atom, []},
314+
{type, Line, byte, []},
315+
{type, Line, integer, []}
316+
]}
317+
]}
313318
]}
314319
]}
315-
]}
316-
]}
317-
]}]
318-
}},
320+
]}]
321+
}};
322+
323+
_ ->
324+
{attribute, Line, spec, {{'__info__', 1},
325+
[{type, Line, 'fun', [
326+
{type, Line, product, [
327+
{type, Line, union, AllowedArgs}
328+
]},
329+
{type, Line, any, []}
330+
]}]
331+
}}
332+
end,
319333

320334
Info =
321335
{function, 0, '__info__', 1, [

lib/elixir/test/elixir/kernel/dialyzer_test.exs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,25 @@ defmodule Kernel.DialyzerTest do
4848
|> String.to_charlist()
4949

5050
File.cp!(context.base_plt, plt)
51-
dialyzer = [analysis_type: :succ_typings, check_plt: false, files_rec: [dir], plts: [plt]]
51+
warnings = Map.get(context, :warnings, [])
52+
53+
dialyzer = [
54+
analysis_type: :succ_typings,
55+
check_plt: false,
56+
files_rec: [dir],
57+
plts: [plt],
58+
warnings: warnings
59+
]
60+
5261
{:ok, [outdir: dir, dialyzer: dialyzer]}
5362
end
5463

64+
@tag warnings: [:specdiffs]
65+
test "no warnings on specdiffs", context do
66+
copy_beam!(context, Dialyzer.RemoteCall)
67+
assert_dialyze_no_warnings!(context)
68+
end
69+
5570
test "no warnings on valid remote calls", context do
5671
copy_beam!(context, Dialyzer.RemoteCall)
5772
assert_dialyze_no_warnings!(context)

0 commit comments

Comments
 (0)