Skip to content

Commit

Permalink
Use intersection type
Browse files Browse the repository at this point in the history
  • Loading branch information
Goose97 committed Sep 1, 2023
1 parent 11428b9 commit e266041
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions lib/elixir_sense/core/metadata_builder.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1690,18 +1690,7 @@ defmodule ElixirSense.Core.MetadataBuilder do
defp type_information_from_guards({:and, _, [guard_l, guard_r]}, state) do
left = type_information_from_guards(guard_l, state)
right = type_information_from_guards(guard_r, state)

Keyword.merge(left, right, fn _k, v1, v2 ->
case {v1, v2} do
# func my_func(x) when is_map_key(x, :a) and is_map_key(x, :b)
{{:map, fields1, _}, {:map, fields2, _}} ->
{:map, Enum.uniq_by(fields1 ++ fields2, &elem(&1, 0)), nil}

# In case we can't merge, just pick one
_ ->
v1
end
end)
{:intersection, [left, right]}
end

defp type_information_from_guards({:or, _, [guard_l, guard_r]}, state) do
Expand Down

0 comments on commit e266041

Please sign in to comment.