Fix to issue 1062: Follow property type references from child declarations when marking #1063
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.
This is a fix to issue #1062 : Follow property type references from child declarations when marking
Root cause
Swift's indexer associates property type references (the type annotation on a
varorlet) with the property declaration itself, not with the enclosing type.UsedDeclarationMarker.markUsed()only walkeddeclaration.referencesanddeclaration.related-- it never descended into child declarations. This meant that when a type was marked as used, types referenced only as property types of its child variable declarations were never discovered.What changed
markUsed()now iterates over child declarations of each used declaration, filtered to variable-kind children only. For each child variable, it follows references that have the.varTyperole. This causes the referenced types to be marked as used transitively.The
.varTypefilter is important: without it, following all references from child variables would over-retain sibling properties that reference each other (e.g., a lazy var referencing a private stored property). By restricting to type references only, the fix targets the specific gap without changing retention behavior for value references between properties.Test changes