Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/elixir/lib/map_set.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions lib/elixir/test/elixir/fixtures/dialyzer/opaqueness.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading