From 6ed75735d57a6e7f4a5c17359c4cd598d6f00345 Mon Sep 17 00:00:00 2001 From: Jakub Melkowski <9402720+Blatts12@users.noreply.github.com> Date: Fri, 13 Oct 2023 08:27:11 +0200 Subject: [PATCH] Add support for `@typep` and `@opaque` --- lib/contexted/delegator.ex | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/contexted/delegator.ex b/lib/contexted/delegator.ex index 9d8ffc4..0efffba 100644 --- a/lib/contexted/delegator.ex +++ b/lib/contexted/delegator.ex @@ -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 @@ -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 ]}