-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[SR-115] Support generic constraints in subscripts #42737
Comments
If anyone is curious or wants to help, I've started a naïve branch here: https://github.com/stephencelis/swift/tree/generic-subscripts I've gotten the parser to stop complaining and am working on getting the resolver to play nicely with subscript access. Once I have things working, I'll submit a pull request and elicit feedback from people with more compiler experience. |
Comment by Johannes Lund (JIRA) Don't know if this should be its own issue, but if the generic subscripts also could be throwing it would be really interesting for all of the Swift JSON deserializers/mappers, including mine https://github.com/Anviking/Decodable |
Comment by Radek Pietruszewski (JIRA) @johannes Related, but deserves its own issue, IMO |
anviking (JIRA User) Yep. Feel free to post another issue and/or start a swift-evolution thread around possible syntax, etc. |
@@slavapestov: Does your implementation support default arguments for subscript parameters? |
Not yet, but I'm waiting for some SILGen work to settle down before looking at that. There's a separate SR tracking default arguments for subscripts, IIRC. |
I could only find SR-4104. |
Comment by Roberto Neira (JIRA) Is there a way to tell in which release of Swift this improvement is included? |
Comment by Roberto Neira (JIRA) @benrimmington Thanks for the quick reply. Is there a way to see which release a fix or improvement will be included in, or a list that shows the fixes/improvements planned for a certain release? |
neirar (JIRA User) The changelog at https://github.com/apple/swift/blob/master/CHANGELOG.md gives a pretty good overview of the high-level changes in each release (including the upcoming release). It also includes this one (search for "Subscript declarations can now be defined to have generic parameter lists"). It doesn't mention every single bugfix, of course. |
Additional Detail from JIRA
md5: ea5cb771b99703784bb1dd3c9e7cf4ed
blocks:
relates to:
Issue Description:
It would really help me and my library (https://github.com/radex/swiftyuserdefaults) to be able to use generic constraints on subscripts, e.g.
subscript<T: SomeProtocol>(key: DefaultsKey<T>) -> T { ... }
@lattner already indicated on the mailing list that this is considered a current language limitation, not a design choice, so I thought it might be useful to have a JIRA issue for tracking progress on this.
The text was updated successfully, but these errors were encountered: