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
7 changes: 7 additions & 0 deletions lib/elixir/lib/task.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,13 @@ defmodule Task do
end
end

# exported only to avoid dialyzer opaqueness check in internal Task modules
@doc false
@spec __alias__(pid()) :: Task.ref()
def __alias__(pid) do
build_alias(pid)
end

## Optimizations

defp build_monitor(pid) do
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/task/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ defmodule Task.Supervisor do
case start_child_with_spec(supervisor, [get_owner(owner), :monitor], :temporary, shutdown) do
{:ok, pid} ->
if link_type == :link, do: Process.link(pid)
alias = :erlang.monitor(:process, pid, alias: :demonitor)
alias = Task.__alias__(pid)
send(pid, {owner, alias, alias, get_callers(owner), {module, fun, args}})
%Task{pid: pid, ref: alias, owner: owner, mfa: {module, fun, length(args)}}

Expand Down
10 changes: 0 additions & 10 deletions lib/elixir/test/elixir/fixtures/dialyzer/opaque_inline.ex

This file was deleted.

17 changes: 17 additions & 0 deletions lib/elixir/test/elixir/fixtures/dialyzer/opaqueness.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule Dialyzer.Opaqueness do
@spec bar(MapSet.t()) :: term()
def bar(set) do
set
end

def foo() do
# inlining of literals should not violate opaqueness check
bar(MapSet.new([1, 2, 3]))
end

# Task.Supervisor returns a Task.t() containing an opaque Task.ref()
@spec run_task() :: Task.t()
def run_task do
Task.Supervisor.async(SupervisorName, fn -> :ok end)
end
end
8 changes: 5 additions & 3 deletions lib/elixir/test/elixir/kernel/dialyzer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ defmodule Kernel.DialyzerTest do
Module,
Protocol,
String,
String.Chars
String.Chars,
Task,
Task.Supervisor
]

files = Enum.map(mods, &:code.which/1)
Expand Down Expand Up @@ -178,8 +180,8 @@ defmodule Kernel.DialyzerTest do
assert_dialyze_no_warnings!(context)
end

test "no warning on inlined calls returning opaque", context do
copy_beam!(context, Dialyzer.OpaqueInline)
test "no warning due to opaqueness edge cases", context do
copy_beam!(context, Dialyzer.Opaqueness)
assert_dialyze_no_warnings!(context)
end

Expand Down