Skip to content

Commit 8dcc969

Browse files
authored
Replace any -> term in modules or functions mixing them (#13872)
1 parent 7fbb7a8 commit 8dcc969

File tree

9 files changed

+19
-19
lines changed

9 files changed

+19
-19
lines changed

lib/elixir/lib/agent.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ defmodule Agent do
284284
instead of an anonymous function; `fun` in `module` will be called with the
285285
given arguments `args` to initialize the state.
286286
"""
287-
@spec start_link(module, atom, [any], GenServer.options()) :: on_start
287+
@spec start_link(module, atom, [term], GenServer.options()) :: on_start
288288
def start_link(module, fun, args, options \\ []) do
289289
GenServer.start_link(Agent.Server, {module, fun, args}, options)
290290
end
@@ -311,7 +311,7 @@ defmodule Agent do
311311
312312
See `start_link/4` for more information.
313313
"""
314-
@spec start(module, atom, [any], GenServer.options()) :: on_start
314+
@spec start(module, atom, [term], GenServer.options()) :: on_start
315315
def start(module, fun, args, options \\ []) do
316316
GenServer.start(Agent.Server, {module, fun, args}, options)
317317
end
@@ -348,7 +348,7 @@ defmodule Agent do
348348
instead of an anonymous function. The state is added as first
349349
argument to the given list of arguments.
350350
"""
351-
@spec get(agent, module, atom, [term], timeout) :: any
351+
@spec get(agent, module, atom, [term], timeout) :: term
352352
def get(agent, module, fun, args, timeout \\ 5000) do
353353
GenServer.call(agent, {:get, {module, fun, args}}, timeout)
354354
end
@@ -389,7 +389,7 @@ defmodule Agent do
389389
instead of an anonymous function. The state is added as first
390390
argument to the given list of arguments.
391391
"""
392-
@spec get_and_update(agent, module, atom, [term], timeout) :: any
392+
@spec get_and_update(agent, module, atom, [term], timeout) :: term
393393
def get_and_update(agent, module, fun, args, timeout \\ 5000) do
394394
GenServer.call(agent, {:get_and_update, {module, fun, args}}, timeout)
395395
end

lib/elixir/lib/gen_event.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ defmodule GenEvent do
4646
@callback init(args :: term) ::
4747
{:ok, state}
4848
| {:ok, state, :hibernate}
49-
| {:error, reason :: any}
50-
when state: any
49+
| {:error, reason :: term}
50+
when state: term
5151

5252
@callback handle_event(event :: term, state :: term) ::
5353
{:ok, new_state}

lib/elixir/lib/gen_server.ex

+4-4
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@ defmodule GenServer do
523523
{:ok, state}
524524
| {:ok, state, timeout | :hibernate | {:continue, continue_arg :: term}}
525525
| :ignore
526-
| {:stop, reason :: any}
527-
when state: any
526+
| {:stop, reason :: term}
527+
when state: term
528528

529529
@doc """
530530
Invoked to handle synchronous `call/3` messages. `call/3` will block until a
@@ -1018,7 +1018,7 @@ defmodule GenServer do
10181018
or `:ignore`, the process is terminated and this function returns
10191019
`{:error, reason}` or `:ignore`, respectively.
10201020
"""
1021-
@spec start_link(module, any, options) :: on_start
1021+
@spec start_link(module, term, options) :: on_start
10221022
def start_link(module, init_arg, options \\ []) when is_atom(module) and is_list(options) do
10231023
do_start(:link, module, init_arg, options)
10241024
end
@@ -1028,7 +1028,7 @@ defmodule GenServer do
10281028
10291029
See `start_link/3` for more information.
10301030
"""
1031-
@spec start(module, any, options) :: on_start
1031+
@spec start(module, term, options) :: on_start
10321032
def start(module, init_arg, options \\ []) when is_atom(module) and is_list(options) do
10331033
do_start(:nolink, module, init_arg, options)
10341034
end

lib/elixir/lib/inspect/algebra.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ defmodule Inspect.Algebra do
438438
439439
"""
440440
@doc since: "1.6.0"
441-
@spec container_doc(t, [any], t, Inspect.Opts.t(), (term, Inspect.Opts.t() -> t), keyword()) ::
441+
@spec container_doc(t, [term], t, Inspect.Opts.t(), (term, Inspect.Opts.t() -> t), keyword()) ::
442442
t
443443
def container_doc(left, collection, right, inspect_opts, fun, opts \\ [])
444444
when is_doc(left) and is_list(collection) and is_doc(right) and is_function(fun, 2) and

lib/elixir/lib/kernel.ex

+2-2
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ defmodule Kernel do
630630
631631
"""
632632
@doc guard: true
633-
@spec hd(nonempty_maybe_improper_list(elem, any)) :: elem when elem: term
633+
@spec hd(nonempty_maybe_improper_list(elem, term)) :: elem when elem: term
634634
def hd(list) do
635635
:erlang.hd(list)
636636
end
@@ -2973,7 +2973,7 @@ defmodule Kernel do
29732973
(term | nil -> {current_value, new_value} | :pop)
29742974
) :: {current_value, new_structure :: structure}
29752975
when structure: Access.t(),
2976-
keys: nonempty_list(any),
2976+
keys: nonempty_list(term),
29772977
current_value: Access.value(),
29782978
new_value: Access.value()
29792979
def get_and_update_in(data, keys, fun)

lib/elixir/lib/map_set.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ defmodule MapSet do
401401
402402
"""
403403
@doc since: "1.15.0"
404-
@spec split_with(MapSet.t(), (any() -> as_boolean(term))) :: {MapSet.t(), MapSet.t()}
404+
@spec split_with(MapSet.t(), (term() -> as_boolean(term))) :: {MapSet.t(), MapSet.t()}
405405
def split_with(%MapSet{map: map}, fun) when is_function(fun, 1) do
406406
{while_true, while_false} = Map.split_with(map, fn {key, _} -> fun.(key) end)
407407
{%MapSet{map: while_true}, %MapSet{map: while_false}}

lib/elixir/lib/regex.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ defmodule Regex do
222222
{:ok, Regex.compile!("foo", [:caseless])}
223223
224224
"""
225-
@spec compile(binary, binary | [term]) :: {:ok, t} | {:error, any}
225+
@spec compile(binary, binary | [term]) :: {:ok, t} | {:error, term}
226226
def compile(source, opts \\ "") when is_binary(source) do
227227
compile(source, opts, version())
228228
end

lib/elixir/lib/registry.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ defmodule Registry do
471471
"""
472472
@doc since: "1.4.0"
473473
@spec dispatch(registry, key, dispatcher, keyword) :: :ok
474-
when dispatcher: (entries :: [{pid, value}] -> term) | {module(), atom(), [any()]}
474+
when dispatcher: (entries :: [{pid, value}] -> term) | {module(), atom(), [term()]}
475475
def dispatch(registry, key, mfa_or_fun, opts \\ [])
476476
when is_atom(registry) and is_function(mfa_or_fun, 1)
477477
when is_atom(registry) and tuple_size(mfa_or_fun) == 3 do

lib/elixir/lib/stream.ex

+3-3
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ defmodule Stream do
878878
"""
879879
@spec transform(Enumerable.t(), acc, fun) :: Enumerable.t()
880880
when fun: (element, acc -> {Enumerable.t(), acc} | {:halt, acc}),
881-
acc: any
881+
acc: term
882882
def transform(enum, acc, reducer) when is_function(reducer, 2) do
883883
&do_transform(enum, fn -> acc end, reducer, &1, &2, nil, fn acc -> acc end)
884884
end
@@ -893,7 +893,7 @@ defmodule Stream do
893893
when start_fun: (-> acc),
894894
reducer: (element, acc -> {Enumerable.t(), acc} | {:halt, acc}),
895895
after_fun: (acc -> term),
896-
acc: any
896+
acc: term
897897
def transform(enum, start_fun, reducer, after_fun)
898898
when is_function(start_fun, 0) and is_function(reducer, 2) and is_function(after_fun, 1) do
899899
&do_transform(enum, start_fun, reducer, &1, &2, nil, after_fun)
@@ -920,7 +920,7 @@ defmodule Stream do
920920
reducer: (element, acc -> {Enumerable.t(), acc} | {:halt, acc}),
921921
last_fun: (acc -> {Enumerable.t(), acc} | {:halt, acc}),
922922
after_fun: (acc -> term),
923-
acc: any
923+
acc: term
924924
def transform(enum, start_fun, reducer, last_fun, after_fun)
925925
when is_function(start_fun, 0) and is_function(reducer, 2) and is_function(last_fun, 1) and
926926
is_function(after_fun, 1) do

0 commit comments

Comments
 (0)