From 4e4f610e4fdce8b0f4e69878f71b345bd5badd6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 31 Aug 2015 21:03:52 +0200 Subject: [PATCH] Forward all info values to get_module_info --- lib/elixir/src/elixir_module.erl | 21 +++++---------------- lib/elixir/test/elixir/kernel_test.exs | 7 +++++++ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/elixir/src/elixir_module.erl b/lib/elixir/src/elixir_module.erl index 33d8f9c54c..30ce7b2da6 100644 --- a/lib/elixir/src/elixir_module.erl +++ b/lib/elixir/src/elixir_module.erl @@ -422,13 +422,7 @@ add_info_function(Line, File, Module, All, Def, Defmacro) -> {attribute, Line, spec, {Pair, [{type, Line, 'fun', [ {type, Line, product, [ - {type, Line, union, [ - {atom, Line, attributes}, - {atom, Line, compile}, - {atom, Line, functions}, - {atom, Line, macros}, - {atom, Line, module} - ]} + {type, Line, atom, []} ]}, {type, Line, union, [ {type, Line, atom, []}, @@ -446,9 +440,7 @@ add_info_function(Line, File, Module, All, Def, Defmacro) -> {function, 0, '__info__', 1, [ functions_clause(Def), macros_clause(Defmacro), - module_clause(Module), - info_clause(Module, attributes), - info_clause(Module, compile) + info_clause(Module) ]}, {Spec, Info} @@ -460,14 +452,11 @@ functions_clause(Def) -> macros_clause(Defmacro) -> {clause, 0, [{atom, 0, macros}], [], [elixir_utils:elixir_to_erl(lists:sort(Defmacro))]}. -module_clause(Module) -> - {clause, 0, [{atom, 0, module}], [], [{atom, 0, Module}]}. - -info_clause(Module, Atom) -> +info_clause(Module) -> Info = {call, 0, {remote, 0, {atom, 0, erlang}, {atom, 0, get_module_info}}, - [{atom, 0, Module}, {atom, 0, Atom}]}, - {clause, 0, [{atom, 0, Atom}], [], [Info]}. + [{atom, 0, Module}, {var, 0, info}]}, + {clause, 0, [{var, 0, info}], [], [Info]}. % HELPERS diff --git a/lib/elixir/test/elixir/kernel_test.exs b/lib/elixir/test/elixir/kernel_test.exs index bcb207f307..612e8adb8c 100644 --- a/lib/elixir/test/elixir/kernel_test.exs +++ b/lib/elixir/test/elixir/kernel_test.exs @@ -197,6 +197,13 @@ defmodule KernelTest do assert not ({:__info__, 1} in Kernel.__info__(:functions)) end + test "__info__(others)" do + assert Kernel.__info__(:module) == Kernel + assert is_list Kernel.__info__(:compile) + assert is_list Kernel.__info__(:attributes) + assert is_list Kernel.__info__(:exports) + end + def exported?, do: not_exported? defp not_exported?, do: true