Skip to content

Discount a reference from a declaration's own span, for every kind - #67

Open
Komoszek wants to merge 3 commits into
mainfrom
claude/issue-58-implementation-rcw0sg
Open

Komoszek wants to merge 3 commits into
mainfrom
claude/issue-58-implementation-rcw0sg

Conversation

@Komoszek

@Komoszek Komoszek commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Groundwork for #58. A function or method called only by itself counted as used; classes already saw through that shape (the unnamed constructor's declaration). The rule is now the same for every kind: a reference inside a declaration's own span keeps nothing alive.

  • ReferenceClassifier: isSelfClassReferenceisSelfReference, applied to every kind; State<Self> pairing stays class-only.
  • CrossLibraryReferences: probes declarations with no reference outside their own span; a use resolving to the declaration it sits in recovers nothing.
  • RemoveSafety: emptiedEnums reads the enum's status, so an enum alive only through its own body is removed whole.
  • Fixture: _countdown, factorial, UsedClass._depth.

Verified on the live server that a first declarator's outline range in int x = 1, y = x + 1; ends at x, so a sibling initializer's reference is not a self-reference.

🤖 Generated with Claude Code

https://claude.ai/code/session_011fqaUyaQtY7AkuTYBjAUJv

A function or method called only by itself counted as used: the
recursive call is a real reference. Classes already saw through that
shape, for the unnamed constructor's declaration. Text inside a
declaration's own span goes when it does, so the rule is the same for
every kind.

The cross-library recovery probes declarations with no reference outside
their own span, and a use that resolves to the declaration it sits in
recovers nothing. An enum kept alive only by its own body is removed
whole, so its values are no longer blocked as an emptied enum.

Groundwork for #58.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011fqaUyaQtY7AkuTYBjAUJv
@Komoszek
Komoszek force-pushed the claude/issue-58-implementation-rcw0sg branch from d4169d6 to 77780ea Compare September 21, 2026 06:19
Comment thread lib/src/reference_classifier.dart Outdated
isSelfReference now runs for every kind, so the class-only convention
got a guard. It never needed one: isStatePairingReference already
requires the reference to be the sole type argument of an `extends
State<…>` clause, which nothing but a class name can be.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011fqaUyaQtY7AkuTYBjAUJv
Comment thread lib/src/cross_library_refs.dart Outdated
_isWithin said what it computed, not why. The probe and the reference
search discount the same shape — a use inside the declaration it would
keep alive — so the helper now carries isSelfReference's name and points
at it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011fqaUyaQtY7AkuTYBjAUJv
@Komoszek
Komoszek marked this pull request as ready for review September 21, 2026 09:40
@Komoszek
Komoszek added this pull request to stack #69 September 21, 2026 09:41
@Komoszek
Komoszek removed this pull request from stack #69 September 22, 2026 06:20
@Komoszek
Komoszek added this pull request to stack #74 September 22, 2026 06:21

This branch has not been deployed

No deployments
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.

2 participants