Skip to content

Fix no_extension_access_modifier rule incorrectly triggering for nonisolated extension#6174

Merged
SimplyDanny merged 4 commits intomainfrom
copilot/fix-6168
Aug 4, 2025
Merged

Fix no_extension_access_modifier rule incorrectly triggering for nonisolated extension#6174
SimplyDanny merged 4 commits intomainfrom
copilot/fix-6168

Conversation

Copy link
Contributor

Copilot AI commented Aug 4, 2025

The no_extension_access_modifier rule was incorrectly flagging nonisolated extension declarations as violations. The nonisolated keyword is an isolation modifier introduced in Swift 6.1, not an access control modifier, so it should not trigger this rule.

Before:

@MainActor
struct Test {}

nonisolated extension Test {} // ❌ No Extension Access Modifier Violation

After:

@MainActor
struct Test {}

nonisolated extension Test {} // ✅ No violation

Changes:

  • Updated the rule logic to only check for actual access control modifiers (private, public, open, internal, fileprivate) using the existing accessLevelModifier property
  • Added nonisolated extension String {} to the non-triggering examples
  • Updated CHANGELOG.md with the fix

The fix leverages the existing DeclModifierSyntax.asAccessLevelModifier utility which correctly distinguishes between access control modifiers and other modifiers like isolation keywords.

Fixes #6168.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: SimplyDanny <16365760+SimplyDanny@users.noreply.github.com>
Copilot AI changed the title [WIP] no_extension_access_modifier rule triggers incorrectly for nonisolated extension Fix no_extension_access_modifier rule incorrectly triggering for nonisolated extension Aug 4, 2025
Copilot AI requested a review from SimplyDanny August 4, 2025 16:41
@SwiftLintBot
Copy link

SwiftLintBot commented Aug 4, 2025

18 Messages
📖 Building this branch resulted in the same binary size as when built on main.
📖 Linting Aerial with this PR took 0.17 s vs 0.17 s on main (0% slower).
📖 Linting Alamofire with this PR took 0.17 s vs 0.17 s on main (0% slower).
📖 Linting Brave with this PR took 0.69 s vs 0.69 s on main (0% slower).
📖 Linting DuckDuckGo with this PR took 2.32 s vs 2.33 s on main (0% faster).
📖 Linting Firefox with this PR took 1.15 s vs 1.14 s on main (0% slower).
📖 Linting Kickstarter with this PR took 0.73 s vs 0.74 s on main (1% faster).
📖 Linting Moya with this PR took 0.13 s vs 0.13 s on main (0% slower).
📖 Linting NetNewsWire with this PR took 0.29 s vs 0.29 s on main (0% slower).
📖 Linting Nimble with this PR took 0.14 s vs 0.15 s on main (6% faster).
📖 Linting PocketCasts with this PR took 0.68 s vs 0.7 s on main (2% faster).
📖 Linting Quick with this PR took 0.12 s vs 0.12 s on main (0% slower).
📖 Linting Realm with this PR took 0.41 s vs 0.42 s on main (2% faster).
📖 Linting Sourcery with this PR took 0.27 s vs 0.27 s on main (0% slower).
📖 Linting Swift with this PR took 0.42 s vs 0.42 s on main (0% slower).
📖 Linting VLC with this PR took 0.2 s vs 0.2 s on main (0% slower).
📖 Linting Wire with this PR took 1.74 s vs 1.78 s on main (2% faster).
📖 Linting WordPress with this PR took 0.96 s vs 0.95 s on main (1% slower).

Generated by 🚫 Danger

Co-authored-by: SimplyDanny <16365760+SimplyDanny@users.noreply.github.com>
@SimplyDanny SimplyDanny marked this pull request as ready for review August 4, 2025 17:05
@SimplyDanny SimplyDanny enabled auto-merge (squash) August 4, 2025 17:07
@SimplyDanny SimplyDanny merged commit 8cda6c6 into main Aug 4, 2025
22 checks passed
@SimplyDanny SimplyDanny deleted the copilot/fix-6168 branch August 4, 2025 17:12
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.

no_extension_access_modifier rule triggers incorrectly for nonisolated extension

3 participants