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

How to use Changeset in protocols? #34

Open
pepasflo opened this issue Mar 17, 2017 · 2 comments
Open

How to use Changeset in protocols? #34

pepasflo opened this issue Mar 17, 2017 · 2 comments

Comments

@pepasflo
Copy link

I can't figure out how to make the compiler happy when trying to express something like this:

public protocol ChangesetApplying: class {
    associatedtype T
    func apply(changeset: Changeset<T>)
}

The above will complain that Type 'Self.T' does not conform to protocol 'Collection'.

Changing it to associatedtype T: Collection yields a different error: Type 'Self.T.Iterator.Element' does not conform to protocol 'Equatable'.

Changing it to associatedtype T: Collection where T.Iterator.Element: Equatable, T.IndexDistance == Int yields the error 'where' clause cannot be attached to an associated type declaration, which appears to be the subject of SE-0142.

Any ideas?

@pepasflo pepasflo changed the title How to use Changeset in protocols? How to use Changeset in protocols? Mar 17, 2017
@ZevEisenberg
Copy link

SE-0142 is implemented for Swift 4. Does this problem still exist in Swift 4?

@pepasflo
Copy link
Author

Thanks for poking this ticket! I don't have Swift 4 installed yet, but I can check back in when I do. In the mean time, if someone else can confirm, that would be great!

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