Skip to content

Commit 4c1f445

Browse files
committed
Type specification to AST conversion should support paren_type
1 parent 0a42d7a commit 4c1f445

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/elixir/lib/kernel/typespec.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ defmodule Kernel.Typespec do
491491
quote do: ...
492492
end
493493

494+
defp typespec_to_ast({:paren_type, _, [type]}) do
495+
typespec_to_ast(type)
496+
end
497+
494498
defp typespec_to_ast({ t, _line, atom }) when is_atom(t) do
495499
atom
496500
end

lib/elixir/test/elixir/typespec_test.exs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@ defmodule Typespec.Test.Type do
328328
quote(hygiene: false, do: my_record() :: {:my_record, field1 :: atom(), field2 :: integer() })
329329
end
330330

331+
test "type_to_ast for paren_type" do
332+
type = {:my_type, {:paren_type, 0, [{:type, 0, :integer, []}]}, []}
333+
assert Kernel.Typespec.type_to_ast(type) ==
334+
quote(hygiene: false, do: my_type() :: integer())
335+
end
336+
331337
test "spec_to_ast" do
332338
specs = [
333339
(quote do: @spec a() :: integer()),

0 commit comments

Comments
 (0)