Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed May 31, 2024
1 parent b19a147 commit ef14f2b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/elixir/lib/module/types/descr.ex
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ defmodule Module.Types.Descr do
end

# For static types, the difference is component-wise.
defp difference_static(left, :term) when not is_optional_static(left), do: none()

defp difference_static(left, right) do
iterator_difference(:maps.next(:maps.iterator(right)), left)
iterator_difference(:maps.next(:maps.iterator(unfold(right))), unfold(left))
end

# Returning 0 from the callback is taken as none() for that subtype.
Expand Down Expand Up @@ -607,16 +609,17 @@ defmodule Module.Types.Descr do

defp dynamic_union(:term, other) when not is_optional_static(other), do: :term
defp dynamic_union(other, :term) when not is_optional_static(other), do: :term
defp dynamic_union(left, right), do: symmetrical_merge(unfold(left), unfold(right), &union/3)

defp dynamic_union(left, right),
do: symmetrical_merge(unfold(left), unfold(right), &union/3)

defp dynamic_intersection(:term, other) when not is_optional_static(other), do: other
defp dynamic_intersection(other, :term) when not is_optional_static(other), do: other

defp dynamic_intersection(left, right),
do: symmetrical_intersection(unfold(left), unfold(right), &intersection/3)

defp dynamic_difference(left, :term) when not is_optional_static(left), do: %{}
defp dynamic_difference(left, right), do: difference_static(unfold(left), unfold(right))
defp dynamic_difference(left, right), do: difference_static(left, right)

defp dynamic_to_quoted(descr) do
cond do
Expand Down

0 comments on commit ef14f2b

Please sign in to comment.