Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion lib/elixir/lib/task.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,10 @@ defmodule Task do
:erlang.monitor(:process, pid)
end

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def build_alias(pid) do
def __alias__(pid) do

So it is not accidentally imported.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call! Perhaps I could keep the defp build_alias too to avoid messing with the optimizations?

:erlang.monitor(:process, pid, alias: :demonitor)
end

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.build_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
Loading