Skip to content

Commit

Permalink
Consolidate extension API
Browse files Browse the repository at this point in the history
  • Loading branch information
arnodirlam committed Nov 6, 2024
1 parent 2c58cf0 commit 28325ff
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions lib/dx/enum.ex
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,15 @@ defmodule Dx.Enum do
{ast, state}
end

def rewrite({{:., meta, [Enum, fun_name]}, meta2, orig_args}, orig_state) do
def rewrite({{:., meta, [Enum, fun_name]}, meta2, orig_args}, state) do
arity = length(orig_args)

{args, state} = Enum.map_reduce(orig_args, orig_state, &Compiler.normalize/2)
{args, state} = Enum.map_reduce(orig_args, state, &Compiler.normalize/2)

maybe_warn_static(meta, fun_name, arity, args, state)

cond do
__scopable?(fun_name, arity) ->
maybe_warn_static(meta, fun_name, arity, args, state)

maybe_warn(meta, fun_name, arity, args, state)

args = Enum.map(args, &Ast.unwrap/1)
Expand All @@ -246,8 +246,6 @@ defmodule Dx.Enum do
|> Loader.add(state)

args_ok?(args, __fn_args(fun_name, arity)) ->
maybe_warn_static(meta, fun_name, arity, args, state)

{args, state} = maybe_preload_scopes(args, __scopable_args(fun_name, arity), state)
args = Enum.map(args, &Ast.unwrap_final_args_inner/1)

Expand All @@ -259,10 +257,6 @@ defmodule Dx.Enum do
{ast, state}

function_exported?(__MODULE__, fun_name, arity) ->
maybe_warn_static(meta, fun_name, arity, args, state)

{args, state} = Enum.map_reduce(orig_args, orig_state, &Compiler.normalize/2)

maybe_warn(meta, fun_name, arity, args, state)

{args, state} = maybe_preload_scopes(args, __scopable_args(fun_name, arity), state)
Expand All @@ -272,10 +266,6 @@ defmodule Dx.Enum do
Loader.add(ast, state)

true ->
maybe_warn_static(meta, fun_name, arity, args, state)

{args, state} = Enum.map_reduce(orig_args, state, &Compiler.normalize/2)

maybe_warn(meta, fun_name, arity, args, state)

{args, state} = maybe_preload_scopes(args, __scopable_args(fun_name, arity), state)
Expand Down

0 comments on commit 28325ff

Please sign in to comment.