Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a type defined in another module implies in compile-time dependency #5087

Closed
rranelli opened this issue Aug 3, 2016 · 3 comments
Closed

Comments

@rranelli
Copy link
Contributor

@rranelli rranelli commented Aug 3, 2016

Environment

  • Elixir version (elixir -v): 1.3.2 & 1.2.6
  • Operating system: debian8 (jessie)

Current behavior

While debugging recompilation issues in my project I noticed that whenever we
add a reference to a type defined in another module in a typespec, the other
module is added as compile-time dependency.

For example, if we have something like this:

## type_a.ex
defmodule TypeA do
  @type t :: integer
end

## type_c.ex
defmodule TypeC do
  @type t :: integer
end

## type_b.ex
defmodule TypeB do
  @spec a() :: TypeA.t
  def a, do: ()

  @spec c() :: TypeC.t
  def c, do: ()
end

I will end up with the following dependency graph:

screenshot from 2016-08-03 13 55 08

This contributes to unnecessary re-compilation. Because of this, some "cycles"
appeared in my project and changing a particular file implied in the
recompilation of 200+ others. I ended up commenting all type declarations and
specs to workaround the issue.

I have been able to reproduce this behavior in both v1.3.2 and v1.2.6.

(I have created a repository to
exemplify the problem.)

Expected behavior

I have talked with @josevalim over IRC about this and it seems to him that this
behavior is a bug.

@josevalim
Copy link
Member

@josevalim josevalim commented Aug 3, 2016

Thank you! We should fix this and backport it. :)

@rranelli
Copy link
Contributor Author

@rranelli rranelli commented Aug 3, 2016

If there is anything I can do to help, let me know 👍

@ericentin
Copy link
Contributor

@ericentin ericentin commented Aug 3, 2016

@josevalim are you still taking a look at this like you were this morning? Happy to work on this if you would prefer to do stuff on GenStage or whatever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.