Skip to content

Fully reset incremental state on clean#2976

Open
jozanek wants to merge 1 commit into
scalacenter:mainfrom
jozanek:fix/1466-clean-stale-analysis
Open

Fully reset incremental state on clean#2976
jozanek wants to merge 1 commit into
scalacenter:mainfrom
jozanek:fix/1466-clean-stale-analysis

Conversation

@jozanek

@jozanek jozanek commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #1466.

Converting a package foo.bar declaration into a top-level object bar of the same name reported bar is already defined as package bar. The error survived "Clean compiling workspace", restarting the build server, and reimporting the build — only rm -rf .bloop cleared it.

Cause

clean deleted the class directories but kept two pieces of incremental state:

  • the persisted Zinc analysis file (<project.out>/<name>-analysis.bin), and
  • the in-memory CompileGatekeeper last-successful result.

After a restart the stale analysis was reloaded and the next compile ran incrementally against it, so the old package foo.bar definition kept colliding with the new object bar. rm -rf .bloop was the only fix because it also removes the analysis file.

Note for reviewers: the analysis file is now deleted for all cleaned targets, not only those with an in-memory successful result — the file can exist on disk even when the in-memory cache has none (e.g. right after a restart), so it can't reuse the existing successful-keyed deletion loop.

Clean deleted the class directories but kept the persisted Zinc analysis,
so after a server restart the stale analysis was reloaded and the next
compile ran incrementally against it. Converting a package into a
top-level object of the same name then kept reporting
"<object> is already defined as package <package>" until .bloop was
removed by hand.

Delete the analysis file for every cleaned target and drop the in-memory
last successful result so clean resets incremental state the same way
removing .bloop does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Converting package to object gives "<object> is already defined as package <package>"

1 participant