What if the foo function has a more serious default implementation? Such as those that exist in ‘GenServer’ for default callbacks implementations(e.g. handle-*)
If the original @DaAnalyst’s question’s code modified as such:
defmodule Abstract do
@callback foo() :: {:ok, binary()} | {:error, binary()}
# EDIT: Even by marking it as optional, Dialyzer complains
@optional_callbacks foo: 0
defmacro __using__(_) do
quote do
@behaviour Abstract
@impl true
def foo() do
{:ok, "Evrything is good:~"}
end
def bar() do
case foo() do
{:ok, message} -> IO.puts(message)
{:error, message} -> IO.puts(message)
end
end
defoverridable foo: 0
end
end
end
defmodule SpecificA do
use Abstract
end
Dialyzer complains:
ElixirLS Dialyzer: The pattern
{'error', _@2} can never match the type
{'ok', <<_:152>>}
How to say/trick Dialyzer to not complain?






















