Skip to content

Commit

Permalink
Remove comp-time error
Browse files Browse the repository at this point in the history
Wasn't able to make it work in the way I intended, think the existing error is better
  • Loading branch information
v0idpwn committed Dec 22, 2024
1 parent 02daaf4 commit 18fb755
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
18 changes: 1 addition & 17 deletions lib/protobuf/dsl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -247,25 +247,9 @@ defmodule Protobuf.DSL do
default_typespec = def_t_typespec(props, extension_props, nil)

quote do
case Code.ensure_compiled(unquote(transform_module_ast)) do
{:module, _} ->
:ok

_ ->
raise CompileError, """
Transform module #{inspect(unquote(transform_module_ast))} not available
during Protobuf definition compilation.
Since Protobuf v0.14, Protobuf definitions depend in compile time on
their transform modules. This means that transform modules can't depend
on Protobuf structs, and must be available for compilation when Protobuf
definitions are compiled.
"""
end

require unquote(transform_module_ast)

if macro_exported?(unquote(transform_module_ast), :typespec, 2) do
if macro_exported?(unquote(transform_module_ast), :typespec, 1) do
unquote(transform_module_ast).typespec(unquote(default_typespec))
else
unquote(default_typespec)
Expand Down
2 changes: 1 addition & 1 deletion test/support/test_msg.ex
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ defmodule TestMsg do

@impl true
defmacro typespec(default_typespec) do
case module do
case __CALLER__.module do
WithTransformModule ->
quote do
@type t() :: integer()
Expand Down

0 comments on commit 18fb755

Please sign in to comment.