Skip to content

Unused imports cause non-deterministic incremental compiles #543

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

Closed
pauldraper opened this issue May 15, 2018 · 4 comments
Closed

Unused imports cause non-deterministic incremental compiles #543

pauldraper opened this issue May 15, 2018 · 4 comments
Labels

Comments

@pauldraper
Copy link

Suppose

  1. Persistent incremental compilation is used.
  2. The compilation has no library dependencies, but imports example.A.
  3. example.jar has a symbol example.A.

Step 1: Compile (fails)
Step 2: Add library dependency example.jar.
Step 3: Compile (succeeds).
Step 4: Remove library dependency example.jar.
Step 5: Compile (succeeds).

Steps 1 and 5 have the same source code, but 1 fails, and 5 succeeds.

@eed3si9n eed3si9n added the bug label May 15, 2018
@jvican
Copy link
Member

jvican commented Aug 27, 2018

I want to fix all non-deterministic behaviours in Zinc, and whenever I sit to do so this ticket will prove useful.

The reason for this change, assuming you're using 2.12, is most likely the unfinished classpath caching implementation in the compiler (not Zinc's fault): you can use -YdisableFlatCpCaching to confirm this is the case. We were bitten by this in our codebase too #282. For more information on what's missing, have a look at scala/scala-dev#416. We're trying to find a solution to correctly cache in scalac and propagate it to Zinc.

@pauldraper
Copy link
Author

This doesn't have to do with 2.12.

This has to do with the fact that Zinc doesn't record information about imports if they are unused. And because the information is not recorded, the compile is no re-run if anything about the imported symbol is change, e.g. the dep is removed.

(A a good workaround of course is to not have unused imports.)

@jvican
Copy link
Member

jvican commented Aug 31, 2018

This issue is a duplication of #226, which describes the same underlying limitation. When I initially registered it, I marked it as wont fix but I have some ideas to correctly teach Zinc to register dependencies in this kind of scenarios, so I'll give updates on the original ticket.

@jvican jvican closed this as completed Aug 31, 2018
@pauldraper
Copy link
Author

Hm...yes. I originally didn't think so, but after a second look, the only way I can reproduce this bug is to use a wildcard import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants