Fix #25894: break cross-unit cyclic export on partial recompile#25900
Open
soronpo wants to merge 2 commits intoscala:mainfrom
Open
Fix #25894: break cross-unit cyclic export on partial recompile#25900soronpo wants to merge 2 commits intoscala:mainfrom
soronpo wants to merge 2 commits intoscala:mainfrom
Conversation
When a file is recompiled against TASTy of its sibling files, resolving an import on the enclosing package can chain into an export in a loaded-from-TASTy sibling that points back at a definition in the file currently being typed, producing a spurious `Cyclic reference involving val <import>`. In `typedPackageDef`, after completing the current source's `<src>$package` class (existing behaviour for i13669), also force-complete any sibling `<src>$package` classes in this package that came from the classpath. This pre-resolves their exports before any import in the current file runs its completer, breaking the cycle. Narrowed to avoid unnecessary work: - skipped for the root / empty package (i13669 is unaffected — it uses the existing top-level call); - only `isDefinedInBinary` `$package` classes are forced, so source- defined siblings still complete in their natural order. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…scala#25797) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a file is recompiled against TASTy of its sibling files, resolving an import on the enclosing package can chain into an export in a loaded-from-TASTy sibling that points back at a definition in the file currently being typed, producing a spurious
Cyclic reference involving val <import>.In
typedPackageDef, after completing the current source's<src>$packageclass (existing behaviour for i13669), also force-complete any sibling<src>$packageclasses in this package that came from the classpath. This pre-resolves their exports before any import in the current file runs its completer, breaking the cycle.Narrowed to avoid unnecessary work:
isDefinedInBinary$packageclasses are forced, so source- defined siblings still complete in their natural order.Fixes #25894
How much have you relied on LLM-based tools in this contribution?
Extensively, but the change is very short. The minimization was hell on earth, even with the help of AI to minimize a 10,000 LOC incremental compilation issue that only happens in sbtn on Windows to 60 LOC that surface the bug without sbt dependency and work on Linux as well.
How was the solution tested?
New automated tests (including the issue's reproducer, if applicable)