Skip to content

Commit 71f7426

Browse files
committed
Mark module attributes as generated in case they contain opaque terms
1 parent 469a1cc commit 71f7426

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3864,6 +3864,11 @@ defmodule Kernel do
38643864
raise ArgumentError,
38653865
"cannot inject attribute @#{name} into function/macro because " <>
38663866
Exception.message(ex)
3867+
else
3868+
# mark module attrs as shallow-generated since the ast for their representation
3869+
# might contain opaque terms
3870+
{caller, meta, args} when is_list(meta) -> {caller, [generated: true] ++ meta, args}
3871+
ast -> ast
38673872
end
38683873
end
38693874

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ defmodule Dialyzer.Opaqueness do
44
set
55
end
66

7-
def foo() do
7+
def inlined do
88
# inlining of literals should not violate opaqueness check
99
bar(MapSet.new([1, 2, 3]))
1010
end
1111

12+
@my_set MapSet.new([1, 2, 3])
13+
def module_attr do
14+
bar(@my_set)
15+
end
16+
1217
# Task.Supervisor returns a Task.t() containing an opaque Task.ref()
1318
@spec run_task() :: Task.t()
1419
def run_task do

0 commit comments

Comments
 (0)