Skip to content

Commit dbf205b

Browse files
author
José Valim
committed
Deprecate Module.function/3
1 parent 0e0bb1c commit dbf205b

File tree

5 files changed

+5
-15
lines changed

5 files changed

+5
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* [Path] Do not normalize paths in `Path.join/2` as normalization is beyond the scope of such function
1717

1818
* Deprecations
19+
* [Module] `Module.function/3` is deprecated, please use `:erlang.make_fun/3` instead
1920

2021
* Backwards incompatible changes
2122

lib/elixir/lib/module.ex

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -476,15 +476,7 @@ defmodule Module do
476476
:elixir_aliases.safe_concat([left, right])
477477
end
478478

479-
@doc """
480-
Gets an anonymous function from the given module, function
481-
and arity. The module and function are not verified to exist.
482-
483-
iex> fun = Module.function(Kernel, :is_atom, 1)
484-
iex> fun.(:hello)
485-
true
486-
487-
"""
479+
@doc false
488480
def function(mod, fun, arity) do
489481
:erlang.make_fun(mod, fun, arity)
490482
end

lib/elixir/src/elixir_dispatch.erl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,5 +522,7 @@ deprecation_message(Warning, Message) ->
522522
Message -> Warning ++ ", " ++ Message
523523
end.
524524

525+
deprecation('Elixir.Module', 'function', 3) ->
526+
"use :erlang.make_fun/3";
525527
deprecation(_, _, _) ->
526528
false.

lib/elixir/test/elixir/module_test.exs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,4 @@ defmodule ModuleTest do
240240
assert Module.definitions_in(__MODULE__, :defp) == []
241241
end
242242
end
243-
244-
test :function do
245-
assert Module.function(:erlang, :atom_to_list, 1).(:hello) == 'hello'
246-
assert is_function Module.function(This, :also_works, 0)
247-
end
248243
end

lib/logger/lib/logger/formatter.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ defmodule Logger.Formatter do
8181
"""
8282

8383
def format({mod, fun}, level, msg, ts, md) do
84-
Module.function(mod, fun, 4).(level, msg, ts, md)
84+
apply(mod, fun, [level, msg, ts, md])
8585
end
8686

8787
def format(config, level, msg, ts, md) do

0 commit comments

Comments
 (0)