Skip to content

Commit 943036d

Browse files
committed
Do not convert user types into types, closes #2086
1 parent 6c184a8 commit 943036d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/ex_doc/language/source.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ defmodule ExDoc.Language.Source do
9292
end
9393

9494
defp expand_records({type, anno, what, args}, records) when type in [:type, :user_type] do
95-
{:type, anno, what, expand_records(args, records)}
95+
{type, anno, what, expand_records(args, records)}
9696
end
9797

9898
defp expand_records({:remote_type, anno, [m, t, args]}, records) do

test/ex_doc/retriever/erlang_test.exs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,12 @@ defmodule ExDoc.Retriever.ErlangTest do
338338
d = 1,
339339
e}).
340340
341-
-type type() :: #a{}.
341+
% We explicitly name the type union because that's an internal type
342+
% and we want to make sure we deal with conflicts properly.
343+
-type union() :: #a{}.
342344
-callback callback() -> #a{}.
343345
344-
-spec function() -> type() | #a{ a :: integer(), b :: integer() }.
346+
-spec function() -> union() | #a{ a :: integer(), b :: integer() }.
345347
function() -> ok.
346348
""")
347349

@@ -351,15 +353,15 @@ defmodule ExDoc.Retriever.ErlangTest do
351353

352354
assert hd(function.specs)
353355
|> Erlang.autolink_spec(current_module: :mod, current_kfa: {:function, :function, 0}) ==
354-
"function() -> <a href=\"#t:type/0\">type</a>() | #a{a :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:integer/0\">integer</a>(), b :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:integer/0\">integer</a>(), c :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:atom/0\">atom</a>(), d :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>(), e :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>()}."
356+
"function() -> <a href=\"#t:union/0\">union</a>() | #a{a :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:integer/0\">integer</a>(), b :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:integer/0\">integer</a>(), c :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:atom/0\">atom</a>(), d :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>(), e :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>()}."
355357

356358
assert hd(callback.specs)
357359
|> Erlang.autolink_spec(current_module: :mod, current_kfa: {:callback, :callback, 0}) ==
358360
"callback() ->\n #a{a :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:pos_integer/0\">pos_integer</a>(), b :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:non_neg_integer/0\">non_neg_integer</a>(), c :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:atom/0\">atom</a>(), d :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>(), e :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>()}."
359361

360362
assert hd(type.specs)
361-
|> Erlang.autolink_spec(current_module: :mod, current_kfa: {:type, :type, 0}) ==
362-
"type() :: #a{a :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:pos_integer/0\">pos_integer</a>(), b :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:non_neg_integer/0\">non_neg_integer</a>(), c :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:atom/0\">atom</a>(), d :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>(), e :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>()}."
363+
|> Erlang.autolink_spec(current_module: :mod, current_kfa: {:type, :union, 0}) ==
364+
"union() :: #a{a :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:pos_integer/0\">pos_integer</a>(), b :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:non_neg_integer/0\">non_neg_integer</a>(), c :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:atom/0\">atom</a>(), d :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>(), e :: <a href=\"https://www.erlang.org/doc/apps/erts/erlang.html#t:term/0\">term</a>()}."
363365
end
364366
end
365367

0 commit comments

Comments
 (0)