Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xcode 8.3 beta 3 is complaining that type doesn't conform to protocol Equatable #6

Closed
WooD1k opened this issue Mar 2, 2017 · 11 comments

Comments

@WooD1k
Copy link

WooD1k commented Mar 2, 2017

I'm getting this error:

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

Here is the code:

struct MessageInfo: EqualsHashable {
    let data: Data
    let hint: String

    static let hashes: Hashes<MessageInfo> = Hashes()
        .append(hashable: { $0.data })
        .append(hashable: { $0.hint })
}

Proposed solution by Xcode:

Equals.EqualsEquatable:3:20: Protocol requires nested type 'Equals'; do you want to add it?

Equals version - 2.0.0

Any thoughts, ideas?

Thanks in advance!

@tomquist
Copy link
Owner

tomquist commented Mar 2, 2017

This seems to work in Xcode 8.2.1 and according to this any Swift code compatible to Swift 3.0 should also compile in 3.1. I'm downloading the latest beta right now and will look into this in detail.

@WooD1k
Copy link
Author

WooD1k commented Mar 2, 2017

@tomquist thanks a bunch!
Yes, everything is okay in Xcode 8.2.1

@WooD1k
Copy link
Author

WooD1k commented Mar 2, 2017

EqualsXcode8_3.zip
@tomquist here is the sample project

@tomquist
Copy link
Owner

tomquist commented Mar 2, 2017

Adding this line to your struct resolves the issue.
typealias Equals = Hashes<MessageInfo>

However I think this is a bug in Swift 3.1. I'll open a Swift bug and link this here.

@WooD1k
Copy link
Author

WooD1k commented Mar 2, 2017

@tomquist after adding a typealias i've seen - Cannot specialize non-generic type 'MessageInfo.Hashes' (aka 'Hashes<MessageInfo>') but i can't reproduce it in sample project

@tomquist
Copy link
Owner

tomquist commented Mar 2, 2017

Try typealias Equals = Equals.Hashes<MessageInfo>

@tomquist
Copy link
Owner

tomquist commented Mar 2, 2017

Oh just tried it but this won't work either because the compiler uses the wrong anchor type to resolve Hashes.
However, this should work (which is a bit ugly):

typealias MessageInfoHashes = Hashes<MessageInfo>
struct MessageInfo: EqualsHashable {
    typealias Equals = MessageInfoHashes
    let data: Data
    let hint: String

    static let hashes: Hashes<MessageInfo> = Hashes()
        .append(hashable: { $0.data })
        .append(hashable: { $0.hint })
}

@tomquist
Copy link
Owner

tomquist commented Mar 2, 2017

I created this Swift Jira issue: https://bugs.swift.org/browse/SR-4143

@tomquist
Copy link
Owner

tomquist commented Mar 3, 2017

Has been fixed in the Swift compiler. Thanks for reporting this issue. I will test this again once the next snapshot is available.

@WooD1k
Copy link
Author

WooD1k commented Mar 9, 2017

@tomquist many thanks for your help and fast feedback!

@tomquist
Copy link
Owner

Fixed in Xcode 8.2 beta 4

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

No branches or pull requests

2 participants