77-include (" elixir.hrl" ).
88
99import (Meta , Ref , Opts , E , Warn , Trace ) ->
10- import (Meta , Ref , Opts , E , Warn , Trace , nil ).
10+ import (Meta , Ref , Opts , E , Warn , Trace , fun Ref : '__info__' / 1 ).
1111
12- import (Meta , Ref , Opts , E , Warn , Trace , InfoCallback ) when is_function ( InfoCallback , 1 ) ->
12+ import (Meta , Ref , Opts , E , Warn , Trace , InfoCallback ) ->
1313 case import_only_except (Meta , Ref , Opts , E , Warn , InfoCallback ) of
1414 {Functions , Macros , Added } ->
1515 Trace andalso elixir_env :trace ({import , [{imported , Added } | Meta ], Ref , Opts }, E ),
@@ -18,9 +18,7 @@ import(Meta, Ref, Opts, E, Warn, Trace, InfoCallback) when is_function(InfoCallb
1818
1919 {error , Reason } ->
2020 {error , Reason }
21- end ;
22- import (Meta , Ref , Opts , E , Warn , Trace , _ ) ->
23- import (Meta , Ref , Opts , E , Warn , Trace , info_callback (Ref )).
21+ end .
2422
2523import_only_except (Meta , Ref , Opts , E , Warn , InfoCallback ) ->
2624 MaybeOnly = lists :keyfind (only , 1 , Opts ),
@@ -85,21 +83,21 @@ import_only_except(Meta, Ref, MaybeOnly, Except, E, Warn, InfoCallback) ->
8583 end .
8684
8785import_listed_functions (Meta , Ref , Only , E , Warn , InfoCallback ) ->
88- New = intersection (Only , InfoCallback ( functions )),
86+ New = intersection (Only , get_functions ( Ref , InfoCallback )),
8987 calculate_key (Meta , Ref , ? key (E , functions ), New , E , Warn ).
9088
9189import_listed_macros (Meta , Ref , Only , E , Warn , InfoCallback ) ->
92- New = intersection (Only , InfoCallback ( macros )),
90+ New = intersection (Only , get_macros ( InfoCallback )),
9391 calculate_key (Meta , Ref , ? key (E , macros ), New , E , Warn ).
9492
9593import_functions (Meta , Ref , Except , E , Warn , InfoCallback ) ->
9694 calculate_except (Meta , Ref , Except , ? key (E , functions ), E , Warn , fun () ->
97- InfoCallback ( functions )
95+ get_functions ( Ref , InfoCallback )
9896 end ).
9997
10098import_macros (Meta , Ref , Except , E , Warn , InfoCallback ) ->
10199 calculate_except (Meta , Ref , Except , ? key (E , macros ), E , Warn , fun () ->
102- InfoCallback ( macros )
100+ get_macros ( InfoCallback )
103101 end ).
104102
105103import_sigil_functions (Meta , Ref , Except , E , Warn , InfoCallback ) ->
@@ -139,19 +137,16 @@ calculate_key(Meta, Key, Old, New, E, Warn) ->
139137
140138% % Retrieve functions and macros from modules
141139
142- info_callback (Module ) ->
143- fun (Kind ) -> info_callback (Module , Kind ) end .
144-
145- info_callback (Module , functions ) ->
140+ get_functions (Module , InfoCallback ) ->
146141 try
147- Module : '__info__' (functions )
142+ InfoCallback (functions )
148143 catch
149144 error :undef -> remove_internals (Module :module_info (exports ))
150- end ;
145+ end .
151146
152- info_callback ( Module , macros ) ->
147+ get_macros ( InfoCallback ) ->
153148 try
154- Module : '__info__' (macros )
149+ InfoCallback (macros )
155150 catch
156151 error :undef -> []
157152 end .
0 commit comments