objcio / core-data

Sample code for the objc.io Core Data book
https://www.objc.io/books/core-data
MIT License
770 stars 198 forks source link

both operands of "===" should be AnyObject #46

Open EdgarDegas opened 6 years ago

PatrickWeigel commented 6 years ago

This eliminates the compiler error. But does it eliminate the root cause? That is, should $0 be Any Object?

tkrajacic commented 6 years ago

~The correct~ A better fix for this would be to change the extension to:

extension Sequence where Element: AnyObject

While the iterator also uses the Element associated type and that one is constrained to be equal to the Sequence's Element type, the type system only checks the Sequence's Element type in this case, so it can't establish that every element of the Sequence is also an AnyObject anyway when only the Iterator's Element is specified.

Hope that makes sense.