Skip to content

Commit 3ca0bdd

Browse files
committed
Fix encoding specs
1 parent e07a915 commit 3ca0bdd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/elixir/lib/json.ex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ defmodule JSON do
199199

200200
@moduledoc since: "1.18.0"
201201

202+
@type encoder :: (term(), encoder() -> iodata())
203+
202204
@type decode_error_reason ::
203205
{:unexpected_end, non_neg_integer()}
204206
| {:invalid_byte, non_neg_integer(), byte()}
@@ -332,7 +334,7 @@ defmodule JSON do
332334
"[123,\"string\",{\"key\":\"value\"}]"
333335
334336
"""
335-
@spec encode!(a, (a -> iodata())) :: binary() when a: var
337+
@spec encode!(term(), encoder()) :: binary()
336338
def encode!(term, encoder \\ &protocol_encode/2) do
337339
IO.iodata_to_binary(encoder.(term, encoder))
338340
end
@@ -353,7 +355,7 @@ defmodule JSON do
353355
"[123,\"string\",{\"key\":\"value\"}]"
354356
355357
"""
356-
@spec encode_to_iodata!(a, (a -> iodata())) :: iodata() when a: var
358+
@spec encode_to_iodata!(term(), encoder()) :: iodata()
357359
def encode_to_iodata!(term, encoder \\ &protocol_encode/2) do
358360
encoder.(term, encoder)
359361
end
@@ -365,7 +367,7 @@ defmodule JSON do
365367
`encode!/2` and `encode_to_iodata!/2`. The default implementation
366368
is an optimized dispatch to the `JSON.Encoder` protocol.
367369
"""
368-
@spec protocol_encode(a, (a -> iodata())) :: iodata() when a: var
370+
@spec protocol_encode(term(), encoder()) :: iodata()
369371
def protocol_encode(value, encoder) when is_atom(value) do
370372
case value do
371373
nil -> "null"

0 commit comments

Comments
 (0)