Clean up synthetic declarations during incremental resolution#739
Closed
st0012 wants to merge 0 commit intodefer-cleanup-emptied-declarationsfrom
Closed
Clean up synthetic declarations during incremental resolution#739st0012 wants to merge 0 commit intodefer-cleanup-emptied-declarationsfrom
st0012 wants to merge 0 commit intodefer-cleanup-emptied-declarationsfrom
Conversation
1c585c2 to
9e7d776
Compare
0d94164 to
4810117
Compare
9e7d776 to
4810117
Compare
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.
Summary
Stacked on #736.
resolve()in a two-level convergence loop: the inner fixpoint resolves pending units, the outer loop runscleanup_empty_declarationsand re-enters resolution if cleanup produced new workcleanup_empty_declarationsto sweep orphaned singleton classes (no definitions, no members, no constant references, no live descendants) alongside the existing TODO cleanupdetach_from_ancestorsto the REMOVE path ofinvalidate_declaration— cleans up stale descendant pointers so the singleton sweep can accurately identify unused singletonshas_no_backing_definitionsto treat empty singletons (no definitions AND no members) as removable, while keeping populated singletons aliveExample
Given
class A::B::C; class << self; def run; end; end; end, the indexer creates TODO declarations forAandA::B, plus a singletonA::B::C::<C>. If the file is deleted:A::B::Cand detaches them fromA::B::C::<C>A::B::Cbecomes empty → removed, cascading to its singleton and parent TODOsWithout this change, the TODO parents and singleton would persist as orphans after deletion.