Ignore module-selected types in prefer_self_in_static_references - #6930
Open
SwastikTripathi wants to merge 1 commit into
Open
SwastikTripathi wants to merge 1 commit into
SwastikTripathi wants to merge 1 commit into
Conversation
A type written with a module selector (`Foundation::TimeInterval`) names a type from that module, so it shouldn't be reported (or corrected to `Self`) just because its name matches the surrounding type. Fixes realm#6924. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #6924.
prefer_self_in_static_referencescompared only the type name, soFoundation::TimeIntervalinsideenum TimeIntervalwas reported, and--fixwould have rewritten it toFoundation::Self. With a module selector the name refers to a type from that module, so the rule now skipsIdentifierTypeSyntaxandDeclReferenceExprSyntaxnodes that have amoduleSelector. Unqualified references (TimeInterval,Date.reference) are reported as before.I added two non-triggering examples covering a return type, a property type and a static member access through
Foundation::. Both fail onmainand pass with the change.swift testpasses in full, and running the built binary on the snippet from the issue now reports only the unqualifiedDate.referencereference.I only looked at this rule. The issue says others may be affected too, but I haven't audited them here.
🤖 Generated with Claude Code