Skip to content

class_delegate_protocol warning triggered by the Actor protocol #6054

@bagofstars

Description

@bagofstars

New Issue Checklist

Bug Description

class_delegate_protocol doesn't recognize the Actor protocol as suitable for being weakly referenced.

protocol FooDelegate: Actor { }

actor Bar {
    weak var delegate: (any FooDelegate)?	// raises warning: Class Delegate Protocol Violation: Delegate protocols should be class-only so they can be weakly referenced (class_delegate_protocol)
}

Since Actor protocol already conforms to AnyObject I believe it can also be whitelisted.

Bonus idea for further consideration: how about renaming the rule into reference_type_delegate_protocol? (I don't have a strong opinion about this one.)

Environment

  • SwiftLint version: 0.59.1
  • Xcode version: 16.3
  • Installation method used: Homebrew

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIdeas for improvements of existing features and rules.good first issueIssue to be taken up by new contributors yet unfamiliar with the project.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions