Skip to content

redundantEquatable removes manually implemented == for types with Any.Type stored properties #2502

@yujingaya

Description

@yujingaya

Similar to the AnyClass case discussed in #2043, Any.Type causes compilation error.

Example:

struct MyStruct: Equatable {
    let ty: Any.Type

    // This cannot be synthesized because Any.Type is not Equatable.
    static func == (lhs: Self, rhs: Self) -> Bool {
        lhs.ty == rhs.ty
    }
}

Current behavior:

SwiftFormat removes the == operator, causing a compilation error:

Type 'MyStruct' does not conform to protocol 'Equatable'

Expected behavior:

SwiftFormat should preserve the manual == implementation when any stored property's type does not conform to Equatable, even if == is available as a free function.

Environment:

  • SwiftFormat 0.59.1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions