Skip to content

Commit 61d82a9

Browse files
authored
More fixes and tests for inlined struct opacity issues (#15063)
* Fix doc -> typedoc * Add regression tests for dialyzer opacity * Do not use opaque :sets.set in MapSet.t()
1 parent 1b0dff7 commit 61d82a9

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

lib/elixir/lib/map_set.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ defmodule MapSet do
5555

5656
@type value :: term
5757

58-
# We don't use opaque because MapSets can be inlined,
58+
# We don't use @opaque (or `:sets.set` which is opaque) because MapSets can be inlined,
5959
# either via module attributes or by the compiler.
60-
@typep internal(value) :: :sets.set(value)
60+
@typep internal(value) :: %{optional(value) => term()}
6161

6262
@type t(value) :: %__MODULE__{map: internal(value)}
6363
@type t :: t(term)

lib/elixir/lib/uri.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ defmodule URI do
3434

3535
# We don't use opaque because URIs can be inlined,
3636
# either via module attributes or by the compiler.
37-
@doc deprecated: "The authority field is deprecated"
37+
@typedoc deprecated: "The authority field is deprecated"
3838
@type authority :: nil | binary
3939

4040
@type t :: %__MODULE__{

lib/elixir/test/elixir/fixtures/dialyzer/regressions.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,10 @@ defmodule Dialyzer.Regressions do
1515
def eex_eval_opts do
1616
EEx.eval_string("foo <%= bar %>", [bar: "baz"], trim: true)
1717
end
18+
19+
@spec inlined_map_set :: MapSet.t(integer())
20+
def inlined_map_set, do: MapSet.new([1, 2])
21+
22+
@spec inlined_uri :: URI.t()
23+
def inlined_uri, do: URI.new!("example.com")
1824
end

lib/elixir/test/elixir/kernel/dialyzer_test.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ defmodule Kernel.DialyzerTest do
3131
:elixir,
3232
:elixir_env,
3333
:elixir_erl_pass,
34+
:inet,
3435
:maps,
3536
:sets,
3637
ArgumentError,
@@ -53,7 +54,8 @@ defmodule Kernel.DialyzerTest do
5354
String,
5455
String.Chars,
5556
Task,
56-
Task.Supervisor
57+
Task.Supervisor,
58+
URI
5759
]
5860

5961
files = Enum.map(mods, &:code.which/1)

0 commit comments

Comments
 (0)