Skip to content

[SR-115] Support generic constraints in subscripts #42737

@swift-ci

Description

@swift-ci
Previous ID SR-115
Radar rdar://problem/21461357
Original Reporter radex (JIRA User)
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 11
Component/s Compiler
Labels Improvement, LanguageFeatureRequest
Assignee @slavapestov
Priority Medium

md5: ea5cb771b99703784bb1dd3c9e7cf4ed

blocks:

  • SR-3460 Replace _AnyHashable protocol with a generic subscript

relates to:

  • SR-238 Support throwing subscripts

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.

Metadata

Metadata

Assignees

Labels

compilerThe Swift compiler itselffeatureA feature request or implementationimprovement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions