Swift: Protocol conformance does not distribute over tuples

Originator:rix.rob
Number:rdar://17478368 Date Originated:26-Jun-2014 09:53 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode6-Beta2 (6A216f)
Classification:Serious Bug Reproducible:Always
 
Summary:
The tuple type (A, A) where A is e.g. Equatable is not itself Equatable. Ditto Hashable.

Likewise for the tuple type (A, B) where A : Hashable, B : Hashable.

I don’t know that this would apply sensibly to *all* protocols (I think it would apply to Collection for example—that’s zip2!—but IntegerLiteralConvertible…?), but Equality, Hashable, and Printable sure seem doable. Unfortunately, they are not doable not by third parties.


Steps to Reproduce:
1. Try to use that sweet memoize { … } combinator from session 404 Advanced Swift to make a function whose parameter type is a tuple of (A, A), where A : Hashable.


Expected Results:
I expected it to succeed.


Actual Results:
It does not—and the error is impossibly opaque.


Regression:
N/A


Notes:
Since you can’t extend tuples, this means you can’t use tuples for any number of valuable tasks.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!