From c7000eff80be26cd002e9e4a2bf8607de698069a Mon Sep 17 00:00:00 2001 From: Davide Sibilio Date: Thu, 24 Oct 2024 12:50:12 +0200 Subject: [PATCH] fix: AutoEquatable Stencil to use `any` for protocols (#1367) * fix: AutoEquatable Stencil to use `any` for protocols * chore: Updated AutoEquatable Expected file --------- Co-authored-by: Davide Sibilio --- Templates/Templates/AutoEquatable.stencil | 2 +- Templates/Tests/Expected/AutoEquatable.expected | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Templates/Templates/AutoEquatable.stencil b/Templates/Templates/AutoEquatable.stencil index b7f74eea..7cd3ce3d 100755 --- a/Templates/Templates/AutoEquatable.stencil +++ b/Templates/Templates/AutoEquatable.stencil @@ -29,7 +29,7 @@ fileprivate func compareArrays(lhs: [T], rhs: [T], compare: (_ lhs: T, _ rhs: // MARK: - {{ type.name }} AutoEquatable {% if not type.kind == "protocol" and not type.based.NSObject %}extension {{ type.name }}: Equatable {}{% endif %} {% if type.supertype.based.Equatable or type.supertype.implements.AutoEquatable or type.supertype|annotated:"AutoEquatable" %}THIS WONT COMPILE, WE DONT SUPPORT INHERITANCE for AutoEquatable{% endif %} -{{ type.accessLevel }} func == (lhs: {{ type.name }}, rhs: {{ type.name }}) -> Bool { +{{ type.accessLevel }} func == (lhs:{% if type.kind == "protocol" %} any{% endif %} {{ type.name }}, rhs:{% if type.kind == "protocol" %} any{% endif %} {{ type.name }}) -> Bool { {% if not type.kind == "protocol" %} {% call compareVariables type.storedVariables %} {% else %} diff --git a/Templates/Tests/Expected/AutoEquatable.expected b/Templates/Tests/Expected/AutoEquatable.expected index c4e87be9..41244df1 100644 --- a/Templates/Tests/Expected/AutoEquatable.expected +++ b/Templates/Tests/Expected/AutoEquatable.expected @@ -58,7 +58,7 @@ internal func == (lhs: AutoEquatableNSObject, rhs: AutoEquatableNSObject) -> Boo return true } // MARK: - AutoEquatableProtocol AutoEquatable -internal func == (lhs: AutoEquatableProtocol, rhs: AutoEquatableProtocol) -> Bool { +internal func == (lhs: any AutoEquatableProtocol, rhs: any AutoEquatableProtocol) -> Bool { guard lhs.width == rhs.width else { return false } guard lhs.height == rhs.height else { return false } guard lhs.name == rhs.name else { return false }