Swift 2b2: Exclusion of same-type requirement in constrained extensions limits their utility
Originator: | rix.rob | ||
Number: | rdar://21512469 | Date Originated: | 23-Jun-2015 06:17 PM |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode-beta (7A121l) |
Classification: | Other Bug | Reproducible: | Always |
Summary: Upon hearing about constrained extensions in Swift 2 beta 2 you might think you could do something fun like implement sum on arrays of ints. You’d be wrong. Steps to Reproduce: 1. This code: struct S<T> {} extension S where T == Int {} Expected Results: should compile Actual Results: but doesn’t: boom.swift:2:21: error: same-type requirement makes generic parameter 'T' non-generic extension S where T == Int {} ^ Regression: N/A Notes: It’s not clear whether this same-type requirement limitation is intended to guard against programmer error or whether it’s an implementation limitation or whether it’s something like an occurs check for the constraints. Whatever the reason, every time I’ve seen it, it’s been standing in the way of something useful I wanted to do.
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!