summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@dashbit.co>2021-12-22 12:47:13 +0100
committerJosé Valim <jose.valim@dashbit.co>2021-12-22 12:47:13 +0100
commita67ed562672a68fe884587cdf42e9538af2447e8 (patch)
tree4ebaa684d06e9f4b3ab9bbba915d2f3cf48c395d
parent86741783b6367efcb8ac02d5fa5aeedd567d4d5b (diff)
downloadelixir-a67ed562672a68fe884587cdf42e9538af2447e8.tar.gz
Simplify context module handling
-rw-r--r--lib/elixir/lib/module/types/of.ex2
-rw-r--r--lib/elixir/src/elixir_expand.erl6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/elixir/lib/module/types/of.ex b/lib/elixir/lib/module/types/of.ex
index cee418cf9..690f4f0fd 100644
--- a/lib/elixir/lib/module/types/of.ex
+++ b/lib/elixir/lib/module/types/of.ex
@@ -237,7 +237,7 @@ defmodule Module.Types.Of do
def remote(module, fun, arity, meta, context) when is_atom(module) do
# TODO: In the future we may want to warn for modules defined
# in the local context
- if Keyword.get(meta, :context_module, false) and context.module != module do
+ if Keyword.get(meta, :context_module, false) do
context
else
ParallelChecker.preload_module(context.cache, module)
diff --git a/lib/elixir/src/elixir_expand.erl b/lib/elixir/src/elixir_expand.erl
index 2d106d5d6..9db95e38d 100644
--- a/lib/elixir/src/elixir_expand.erl
+++ b/lib/elixir/src/elixir_expand.erl
@@ -841,6 +841,12 @@ expand_remote(Receiver, DotMeta, Right, Meta, Args, _, _, E) ->
attach_context_module(_Receiver, Meta, #{function := nil}) ->
Meta;
+attach_context_module(Receiver, Meta, #{context_modules := [Ctx | _], module := Mod})
+ %% If the context is the current module or
+ %% if the receiver is the current module,
+ %% then there is no context module.
+ when Ctx == Mod; Receiver == Mod ->
+ Meta;
attach_context_module(Receiver, Meta, #{context_modules := ContextModules}) ->
case lists:member(Receiver, ContextModules) of
true -> [{context_module, true} | Meta];