diff --git a/lib/elixir/src/elixir_map.erl b/lib/elixir/src/elixir_map.erl index 1348629563..e235613a14 100644 --- a/lib/elixir/src/elixir_map.erl +++ b/lib/elixir/src/elixir_map.erl @@ -19,7 +19,7 @@ expand_struct(Meta, Left, Right, #{context := Context} = E) -> true when is_atom(ELeft) -> %% We always record structs when they are expanded %% as they expect the reference at compile time. - elixir_lexical:record_remote(ELeft, nil, ?m(E, lexical_tracker)); + elixir_lexical:record_remote(ELeft, '__struct__', 1, nil, ?line(Meta), ?m(E, lexical_tracker)); true -> ok; false when Context == match -> diff --git a/lib/elixir/test/elixir/kernel/lexical_tracker_test.exs b/lib/elixir/test/elixir/kernel/lexical_tracker_test.exs index 52218282bb..2384007dce 100644 --- a/lib/elixir/test/elixir/kernel/lexical_tracker_test.exs +++ b/lib/elixir/test/elixir/kernel/lexical_tracker_test.exs @@ -161,6 +161,7 @@ defmodule Kernel.LexicalTrackerTest do &R.func/0 &Remote.func/0 &Integer.is_even/1 + %Macro.Env{} end &extract/2 @@ -171,6 +172,8 @@ defmodule Kernel.LexicalTrackerTest do &is_record/1; def b(a), do: is_record(a) + %Macro.Env{} + Kernel.LexicalTracker.remote_dispatches(__ENV__.module) end |> elem(3) """) @@ -181,14 +184,16 @@ defmodule Kernel.LexicalTrackerTest do assert {9, Integer, :is_even, 1} in compile_remote_calls assert {15, Record, :is_record, 1} in compile_remote_calls assert {18, Integer, :is_even, 1} in compile_remote_calls - assert {21, Record, :extract, 2} in compile_remote_calls - assert {22, Record, :is_record, 1} in compile_remote_calls - assert {23, Remote, :func, 0} in compile_remote_calls + assert {19, Macro.Env, :__struct__, 1} in compile_remote_calls + assert {22, Record, :extract, 2} in compile_remote_calls + assert {23, Record, :is_record, 1} in compile_remote_calls assert {24, Remote, :func, 0} in compile_remote_calls - assert {25, Integer, :is_even, 1} in compile_remote_calls - assert {27, Kernel, :def, 2} in compile_remote_calls - assert {27, Record, :is_record, 1} in compile_remote_calls - assert {29, Kernel.LexicalTracker, :remote_dispatches, 1} in compile_remote_calls + assert {25, Remote, :func, 0} in compile_remote_calls + assert {26, Integer, :is_even, 1} in compile_remote_calls + assert {28, Kernel, :def, 2} in compile_remote_calls + assert {28, Record, :is_record, 1} in compile_remote_calls + assert {30, Macro.Env, :__struct__, 1} in compile_remote_calls + assert {32, Kernel.LexicalTracker, :remote_dispatches, 1} in compile_remote_calls runtime_remote_calls = unroll_dispatches(runtime_remote_calls) assert {7, Record, :extract, 2} in runtime_remote_calls @@ -200,7 +205,7 @@ defmodule Kernel.LexicalTrackerTest do assert {16, Remote, :func, 0} in runtime_remote_calls assert {17, Remote, :func, 0} in runtime_remote_calls assert {18, :erlang, :==, 2} in runtime_remote_calls - assert {27, :erlang, :is_tuple, 1} in runtime_remote_calls + assert {28, :erlang, :is_tuple, 1} in runtime_remote_calls end defp unroll_dispatches(dispatches) do