diff --git a/lib/elixir/lib/map_set.ex b/lib/elixir/lib/map_set.ex index 67bd429a1c8..fbfd9c303c1 100644 --- a/lib/elixir/lib/map_set.ex +++ b/lib/elixir/lib/map_set.ex @@ -57,7 +57,8 @@ defmodule MapSet do # We don't use @opaque (or `:sets.set` which is opaque) because MapSets can be inlined, # either via module attributes or by the compiler. - @typep internal(value) :: %{optional(value) => term()} + # Defaulting to a broad `term()` type to prevent opaqueness violations. + @typep internal(_value) :: term() @type t(value) :: %__MODULE__{map: internal(value)} @type t :: t(term) diff --git a/lib/elixir/test/elixir/fixtures/dialyzer/opaqueness.ex b/lib/elixir/test/elixir/fixtures/dialyzer/opaqueness.ex index d8371c386e5..177c5f35f8f 100644 --- a/lib/elixir/test/elixir/fixtures/dialyzer/opaqueness.ex +++ b/lib/elixir/test/elixir/fixtures/dialyzer/opaqueness.ex @@ -14,6 +14,11 @@ defmodule Dialyzer.Opaqueness do bar(@my_set) end + def contains?(ids, id) do + id_set = MapSet.new(ids) + MapSet.member?(id_set, id) + end + # Task.Supervisor returns a Task.t() containing an opaque Task.ref() @spec run_task() :: Task.t() def run_task do