Skip to content

Commit

Permalink
Annotate function definition and not when guard
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Oct 23, 2023
1 parent c35d002 commit 9581ba7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lib/elixir/src/elixir_quote.erl
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,18 @@ keynew(Key, Meta, Value) ->
%% expressions, so we need to clean up the forms to
%% allow them to get a new counter on the next expansion.

annotate({Def, Meta, [{H, M, A} | T]}, Context) when ?defs(Def) ->
{Def, Meta, [{H, keystore(context, M, Context), A} | T]};
annotate({{'.', _, [_, Def]} = Target, Meta, [{H, M, A} | T]}, Context) when ?defs(Def) ->
{Target, Meta, [{H, keystore(context, M, Context), A} | T]};

annotate({Def, Meta, [H | T]}, Context) when ?defs(Def) ->
{Def, Meta, [annotate_def(H, Context) | T]};
annotate({{'.', _, [_, Def]} = Target, Meta, [H | T]}, Context) when ?defs(Def) ->
{Target, Meta, [annotate_def(H, Context) | T]};
annotate({Lexical, Meta, [_ | _] = Args}, Context) when ?lexical(Lexical) ->
NewMeta = keystore(context, keydelete(counter, Meta), Context),
{Lexical, NewMeta, Args};
annotate(Tree, _Context) -> Tree.
annotate(Tree, _Context) -> Tree.

annotate_def({'when', Meta, [Left, Right]}, Context) ->
{'when', Meta, [annotate_def(Left, Context), Right]};
annotate_def({Fun, Meta, Args}, Context) ->
{Fun, keystore(context, Meta, Context), Args};
annotate_def(Other, _Context) ->
Other.

0 comments on commit 9581ba7

Please sign in to comment.