Skip to content

Replace any -> term in modules or functions mixing them #13872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/elixir/lib/agent.ex
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ defmodule Agent do
instead of an anonymous function; `fun` in `module` will be called with the
given arguments `args` to initialize the state.
"""
@spec start_link(module, atom, [any], GenServer.options()) :: on_start
@spec start_link(module, atom, [term], GenServer.options()) :: on_start
def start_link(module, fun, args, options \\ []) do
GenServer.start_link(Agent.Server, {module, fun, args}, options)
end
Expand All @@ -311,7 +311,7 @@ defmodule Agent do

See `start_link/4` for more information.
"""
@spec start(module, atom, [any], GenServer.options()) :: on_start
@spec start(module, atom, [term], GenServer.options()) :: on_start
def start(module, fun, args, options \\ []) do
GenServer.start(Agent.Server, {module, fun, args}, options)
end
Expand Down Expand Up @@ -348,7 +348,7 @@ defmodule Agent do
instead of an anonymous function. The state is added as first
argument to the given list of arguments.
"""
@spec get(agent, module, atom, [term], timeout) :: any
@spec get(agent, module, atom, [term], timeout) :: term
def get(agent, module, fun, args, timeout \\ 5000) do
GenServer.call(agent, {:get, {module, fun, args}}, timeout)
end
Expand Down Expand Up @@ -389,7 +389,7 @@ defmodule Agent do
instead of an anonymous function. The state is added as first
argument to the given list of arguments.
"""
@spec get_and_update(agent, module, atom, [term], timeout) :: any
@spec get_and_update(agent, module, atom, [term], timeout) :: term
def get_and_update(agent, module, fun, args, timeout \\ 5000) do
GenServer.call(agent, {:get_and_update, {module, fun, args}}, timeout)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/lib/gen_event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ defmodule GenEvent do
@callback init(args :: term) ::
{:ok, state}
| {:ok, state, :hibernate}
| {:error, reason :: any}
when state: any
| {:error, reason :: term}
when state: term

@callback handle_event(event :: term, state :: term) ::
{:ok, new_state}
Expand Down
8 changes: 4 additions & 4 deletions lib/elixir/lib/gen_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,8 @@ defmodule GenServer do
{:ok, state}
| {:ok, state, timeout | :hibernate | {:continue, continue_arg :: term}}
| :ignore
| {:stop, reason :: any}
when state: any
| {:stop, reason :: term}
when state: term

@doc """
Invoked to handle synchronous `call/3` messages. `call/3` will block until a
Expand Down Expand Up @@ -1018,7 +1018,7 @@ defmodule GenServer do
or `:ignore`, the process is terminated and this function returns
`{:error, reason}` or `:ignore`, respectively.
"""
@spec start_link(module, any, options) :: on_start
@spec start_link(module, term, options) :: on_start
def start_link(module, init_arg, options \\ []) when is_atom(module) and is_list(options) do
do_start(:link, module, init_arg, options)
end
Expand All @@ -1028,7 +1028,7 @@ defmodule GenServer do

See `start_link/3` for more information.
"""
@spec start(module, any, options) :: on_start
@spec start(module, term, options) :: on_start
def start(module, init_arg, options \\ []) when is_atom(module) and is_list(options) do
do_start(:nolink, module, init_arg, options)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/inspect/algebra.ex
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ defmodule Inspect.Algebra do

"""
@doc since: "1.6.0"
@spec container_doc(t, [any], t, Inspect.Opts.t(), (term, Inspect.Opts.t() -> t), keyword()) ::
@spec container_doc(t, [term], t, Inspect.Opts.t(), (term, Inspect.Opts.t() -> t), keyword()) ::
t
def container_doc(left, collection, right, inspect_opts, fun, opts \\ [])
when is_doc(left) and is_list(collection) and is_doc(right) and is_function(fun, 2) and
Expand Down
4 changes: 2 additions & 2 deletions lib/elixir/lib/kernel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ defmodule Kernel do

"""
@doc guard: true
@spec hd(nonempty_maybe_improper_list(elem, any)) :: elem when elem: term
@spec hd(nonempty_maybe_improper_list(elem, term)) :: elem when elem: term
def hd(list) do
:erlang.hd(list)
end
Expand Down Expand Up @@ -2973,7 +2973,7 @@ defmodule Kernel do
(term | nil -> {current_value, new_value} | :pop)
) :: {current_value, new_structure :: structure}
when structure: Access.t(),
keys: nonempty_list(any),
keys: nonempty_list(term),
current_value: Access.value(),
new_value: Access.value()
def get_and_update_in(data, keys, fun)
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/map_set.ex
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ defmodule MapSet do

"""
@doc since: "1.15.0"
@spec split_with(MapSet.t(), (any() -> as_boolean(term))) :: {MapSet.t(), MapSet.t()}
@spec split_with(MapSet.t(), (term() -> as_boolean(term))) :: {MapSet.t(), MapSet.t()}
def split_with(%MapSet{map: map}, fun) when is_function(fun, 1) do
{while_true, while_false} = Map.split_with(map, fn {key, _} -> fun.(key) end)
{%MapSet{map: while_true}, %MapSet{map: while_false}}
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/regex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ defmodule Regex do
{:ok, Regex.compile!("foo", [:caseless])}

"""
@spec compile(binary, binary | [term]) :: {:ok, t} | {:error, any}
@spec compile(binary, binary | [term]) :: {:ok, t} | {:error, term}
def compile(source, opts \\ "") when is_binary(source) do
compile(source, opts, version())
end
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/registry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ defmodule Registry do
"""
@doc since: "1.4.0"
@spec dispatch(registry, key, dispatcher, keyword) :: :ok
when dispatcher: (entries :: [{pid, value}] -> term) | {module(), atom(), [any()]}
when dispatcher: (entries :: [{pid, value}] -> term) | {module(), atom(), [term()]}
def dispatch(registry, key, mfa_or_fun, opts \\ [])
when is_atom(registry) and is_function(mfa_or_fun, 1)
when is_atom(registry) and tuple_size(mfa_or_fun) == 3 do
Expand Down
6 changes: 3 additions & 3 deletions lib/elixir/lib/stream.ex
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ defmodule Stream do
"""
@spec transform(Enumerable.t(), acc, fun) :: Enumerable.t()
when fun: (element, acc -> {Enumerable.t(), acc} | {:halt, acc}),
acc: any
acc: term
def transform(enum, acc, reducer) when is_function(reducer, 2) do
&do_transform(enum, fn -> acc end, reducer, &1, &2, nil, fn acc -> acc end)
end
Expand All @@ -893,7 +893,7 @@ defmodule Stream do
when start_fun: (-> acc),
reducer: (element, acc -> {Enumerable.t(), acc} | {:halt, acc}),
after_fun: (acc -> term),
acc: any
acc: term
def transform(enum, start_fun, reducer, after_fun)
when is_function(start_fun, 0) and is_function(reducer, 2) and is_function(after_fun, 1) do
&do_transform(enum, start_fun, reducer, &1, &2, nil, after_fun)
Expand All @@ -920,7 +920,7 @@ defmodule Stream do
reducer: (element, acc -> {Enumerable.t(), acc} | {:halt, acc}),
last_fun: (acc -> {Enumerable.t(), acc} | {:halt, acc}),
after_fun: (acc -> term),
acc: any
acc: term
def transform(enum, start_fun, reducer, last_fun, after_fun)
when is_function(start_fun, 0) and is_function(reducer, 2) and is_function(last_fun, 1) and
is_function(after_fun, 1) do
Expand Down
Loading