Closed jesperes closed 3 years ago
The problem is in meck_code:rename_module/2
which only modifieds the module
attribute, and ignores any typespecs found in the file:
-spec rename_module(erlang_form(), module()) -> erlang_form().
rename_module([{attribute, Line, module, OldAttribute}|T], NewName) ->
case OldAttribute of
{_OldName, Variables} ->
[{attribute, Line, module, {NewName, Variables}}|T];
_OldName ->
[{attribute, Line, module, NewName}|T]
end;
rename_module([H|T], NewName) ->
[H|rename_module(T, NewName)].
Thanks for the pointer! I'll take a look at as soon as I can.
Module references in typespecs are not included when renaming modules. This causes problems with OTP 22, as specs referencing functions in other modules are no longer permitted. See e.g. OTP-15563 in http://erlang.org/download/otp_src_22.0.readme:
Reproduction Steps
Given the following module:
Compile
foo.erl
witherlc +debug_info foo.erl
Start an Erlang shell and call
mock:new(foo, [passthrough])
Expected behavior
mock:new/2
should returnok
.Observed behavior
mock:new/2
throws an exception:Versions