Skip to content

Commit 16a55b1

Browse files
committed
Do not generate compile-time deps when expanding literals, closes #3592
1 parent a00ba4f commit 16a55b1

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

lib/phoenix_component.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,8 +1975,8 @@ defmodule Phoenix.Component do
19751975
'''
19761976
@doc type: :macro
19771977
defmacro attr(name, type, opts \\ []) do
1978-
type = Macro.expand_literals(type, __CALLER__)
1979-
opts = Macro.expand_literals(opts, __CALLER__)
1978+
type = Macro.expand_literals(type, %{__CALLER__ | function: {:attr, 3}})
1979+
opts = Macro.expand_literals(opts, %{__CALLER__ | function: {:attr, 3}})
19801980

19811981
quote bind_quoted: [name: name, type: type, opts: opts] do
19821982
Phoenix.Component.Declarative.__attr__!(

lib/phoenix_live_view.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,16 +542,18 @@ defmodule Phoenix.LiveView do
542542
543543
"""
544544
defmacro on_mount(mod_or_mod_arg) do
545+
caller = %{__CALLER__ | function: {:on_mount, 1}}
546+
545547
# While we could pass `mod_or_mod_arg` as a whole to
546548
# expand_literals, we want to also be able to expand only
547549
# the first element, even if the second element is not a literal.
548550
mod_or_mod_arg =
549551
case mod_or_mod_arg do
550552
{mod, arg} ->
551-
{Macro.expand_literals(mod, __CALLER__), Macro.expand_literals(arg, __CALLER__)}
553+
{Macro.expand_literals(mod, caller), Macro.expand_literals(arg, caller)}
552554

553555
mod_or_mod_arg ->
554-
Macro.expand_literals(mod_or_mod_arg, __CALLER__)
556+
Macro.expand_literals(mod_or_mod_arg, caller)
555557
end
556558

557559
quote do

lib/phoenix_live_view/router.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ defmodule Phoenix.LiveView.Router do
105105
106106
"""
107107
defmacro live(path, live_view, action \\ nil, opts \\ []) do
108-
live_view = Macro.expand_literals(live_view, __CALLER__)
109-
action = Macro.expand_literals(action, __CALLER__)
110-
opts = Macro.expand_literals(opts, __CALLER__)
108+
live_view = Macro.expand_literals(live_view, %{__CALLER__ | function: {:live, 4}})
109+
action = Macro.expand_literals(action, %{__CALLER__ | function: {:live, 4}})
110+
opts = Macro.expand_literals(opts, %{__CALLER__ | function: {:live, 4}})
111111

112112
quote bind_quoted: binding() do
113113
{action, router_options} =
@@ -227,7 +227,7 @@ defmodule Phoenix.LiveView.Router do
227227
and be executed via `on_mount` hooks.
228228
"""
229229
defmacro live_session(name, opts \\ [], do: block) do
230-
opts = Macro.expand_literals(opts, __CALLER__)
230+
opts = Macro.expand_literals(opts, %{__CALLER__ | function: {:live_session, 3}})
231231

232232
quote do
233233
unquote(__MODULE__).__live_session__(__MODULE__, unquote(opts), unquote(name))

0 commit comments

Comments
 (0)