Skip to content

Commit

Permalink
Don't move nested modules into custom env
Browse files Browse the repository at this point in the history
  • Loading branch information
Manuel Bärenz committed Dec 26, 2020
1 parent 98cb354 commit abf7a7c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/ex_type/custom_env.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,15 @@ defmodule ExType.CustomEnv do
# create new module with name: ExType.Module.XXX
defmacro defmodule(alias, do: block) do
{:__aliases__, meta, tokens} = alias
new_alias = {:__aliases__, meta, [:ExType, :Module | tokens]}

# Don't move nested modules into custom env (https://github.com/gyson/ex_type/issues/23)
env = __CALLER__
new_alias_prefix = case env.module do
nil -> [:ExType, :Module]
_ -> []
end

new_alias = {:__aliases__, meta, new_alias_prefix ++ tokens}

quote do
Kernel.defmodule unquote(new_alias) do
Expand Down

0 comments on commit abf7a7c

Please sign in to comment.