Skip to content

Commit 41d1a72

Browse files
committed
Do not skip dynamic for indivisible types inside functions
1 parent 65e084e commit 41d1a72

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/elixir/lib/module/types/descr.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,8 @@ defmodule Module.Types.Descr do
16181618
end
16191619

16201620
defp fun_pos_to_quoted([_ | _] = pos, opts) do
1621+
opts = Keyword.put(opts, :skip_dynamic_for_indivisible, false)
1622+
16211623
pos
16221624
|> Enum.sort()
16231625
|> Enum.map(&fun_intersection_to_quoted(&1, opts))
@@ -2034,7 +2036,7 @@ defmodule Module.Types.Descr do
20342036
term_type?(descr) ->
20352037
[{:dynamic, [], []}]
20362038

2037-
single = indivisible_bitmap(descr) ->
2039+
single = indivisible_bitmap(descr, opts) ->
20382040
[single]
20392041

20402042
true ->
@@ -2045,8 +2047,9 @@ defmodule Module.Types.Descr do
20452047
end
20462048
end
20472049

2048-
defp indivisible_bitmap(descr) do
2049-
with %{bitmap: bitmap} when map_size(descr) == 1 <- descr,
2050+
defp indivisible_bitmap(descr, opts) do
2051+
with true <- Keyword.get(opts, :skip_dynamic_for_indivisible, true),
2052+
%{bitmap: bitmap} when map_size(descr) == 1 <- descr,
20502053
[single] <- bitmap_to_quoted(bitmap) do
20512054
single
20522055
else

lib/elixir/test/elixir/module/types/descr_test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,6 +1818,9 @@ defmodule Module.Types.DescrTest do
18181818
end
18191819

18201820
test "function with dynamic signatures" do
1821+
assert fun([dynamic(integer())], float()) |> to_quoted_string() ==
1822+
"(dynamic(integer()) -> float())"
1823+
18211824
assert fun([dynamic(atom())], float()) |> to_quoted_string() ==
18221825
"(dynamic(atom()) -> float())"
18231826

0 commit comments

Comments
 (0)