SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

class_delegate_protocol warning triggered by the Actor protocol

Open bagofstars opened this issue 7 months ago • 2 comments

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

bagofstars avatar Apr 16 '25 21:04 bagofstars

Hi! I'd like to work on this issue. It's ok?

carloshpdoc avatar Apr 28 '25 00:04 carloshpdoc

Hi! I'd like to work on this issue. It's ok?

Absolutely!

mildm8nnered avatar Apr 28 '25 01:04 mildm8nnered

Has there been any progress on this issue? (@carloshpdoc)

wvteijlingen-npo avatar Jul 24 '25 15:07 wvteijlingen-npo

Has there been any progress on this issue? (@carloshpdoc)

The issue has been fixed by #6067.

SimplyDanny avatar Jul 24 '25 16:07 SimplyDanny