Skip to content

Commit 5e1e2e6

Browse files
author
José Valim
committed
Inject less code when reading @Attribute
1 parent 77d708e commit 5e1e2e6

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,7 +2709,10 @@ defmodule Kernel do
27092709
case function? do
27102710
true ->
27112711
value =
2712-
with {_, doc} when doc_attr? <- Module.get_attribute(env.module, name, stack), do: doc
2712+
case Module.get_attribute(env.module, name, stack) do
2713+
{_, doc} when doc_attr? -> doc
2714+
other -> other
2715+
end
27132716

27142717
try do
27152718
:elixir_quote.escape(value, false)
@@ -2722,13 +2725,21 @@ defmodule Kernel do
27222725
{val, _} -> val
27232726
end
27242727

2728+
false when doc_attr? ->
2729+
{escaped, _} = :elixir_quote.escape(stack, false)
2730+
2731+
quote do
2732+
case Module.get_attribute(__MODULE__, unquote(name), unquote(escaped)) do
2733+
{_, doc} -> doc
2734+
other -> other
2735+
end
2736+
end
2737+
27252738
false ->
27262739
{escaped, _} = :elixir_quote.escape(stack, false)
27272740

27282741
quote do
2729-
with {_, doc} when unquote(doc_attr?) <-
2730-
Module.get_attribute(__MODULE__, unquote(name), unquote(escaped)),
2731-
do: doc
2742+
Module.get_attribute(__MODULE__, unquote(name), unquote(escaped))
27322743
end
27332744
end
27342745
end

0 commit comments

Comments
 (0)