Skip to content

Commit

Permalink
Add support for @typep and @opaque
Browse files Browse the repository at this point in the history
  • Loading branch information
Blatts12 committed Oct 13, 2023
1 parent a0bcd63 commit 6ed7573
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/contexted/delegator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ defmodule Contexted.Delegator do
case Code.Typespec.fetch_types(module) do
{:ok, types} ->
Enum.map(types, fn
{:type, type} ->
{type_of_type, type} ->
Code.Typespec.type_to_quoted(type)
|> add_type_ast()
|> add_ast_for_type(type_of_type)

_ ->
nil
Expand All @@ -108,11 +108,11 @@ defmodule Contexted.Delegator do
end
end

@spec add_type_ast(tuple()) :: tuple()
defp add_type_ast(ast) do
@spec add_ast_for_type(tuple(), atom()) :: tuple()
defp add_ast_for_type(ast, type_of_type) do
{:@, [context: Elixir, imports: [{1, Kernel}]],
[
{:type, [context: Elixir],
{type_of_type, [context: Elixir],
[
ast
]}
Expand Down

0 comments on commit 6ed7573

Please sign in to comment.