Skip to content
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-64] Allow generic parameters on typealiases #42686

Closed
lilyball mannequin opened this issue Dec 5, 2015 · 9 comments
Closed

[SR-64] Allow generic parameters on typealiases #42686

lilyball mannequin opened this issue Dec 5, 2015 · 9 comments
Labels
compiler The Swift compiler in itself feature A feature request or implementation improvement

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Dec 5, 2015

Previous ID SR-64
Radar None
Original Reporter @lilyball
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, LanguageFeatureRequest
Assignee None
Priority Medium

md5: 1ffbbd3dbec72831eafe2d1921c680d6

Issue Description:

It would be really handy if typealiases could take generic parameters, e.g.

typealias Handler<Element> = [Element] -> Void
@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Dec 5, 2015

This was already discussed on swift-evolution: https://lists.swift.org/pipermail/swift-evolution/2015-December/000132.html

The consensus is this is an obviously desirable feature.

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 5, 2015

Comment by Austin Zheng (JIRA)

So, how would this work? If I hypothetically wanted to work on the task, would I assign it to myself? What if someone else wanted to work on it as well? Should there be discussion first? (Sorry, new to Jira in the context of open-source projects.)

@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Dec 5, 2015

Good question. I've never used JIRA with open-source projects before, just GitHub Issues (where assigning is rare). My inclination is that if you want to work on something where you'll have a patch soon, or where if you don't have a patch soon you'll abandon it (e.g. you aren't sure if you have the requisite knowledge to fix it but you want to give it a shot), then you should just submit a patch. But if you're worried that someone else might start working on it at the same time and you don't want to duplicate effort, then certainly saying something is a good idea. Whether or not you should actually assign it to yourself is something that the core team probably has to decide.

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 5, 2015

Comment by Austin Zheng (JIRA)

Thanks for the insight. I'd like to take a shot at it, but I wouldn't want to stop anyone else who also wanted to try working on it. I guess this Jira comment thread is as good a place as any to discuss who'd be interested in working on what.

@belkadan
Copy link
Contributor

belkadan commented Dec 8, 2015

++Kevin. The next step for the feature is getting a formal proposal through the Swift Language Process, but this bug report can be used to track implementation progress. I'd expect anyone to read the comments before assigning the bug to themselves, so not marking yourself as assignee while you're just toying around with it seems appropriate.

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 8, 2015

Comment by Austin Zheng (JIRA)

Right. Based on the discussion it seems like the exact implementation won't be straightforward, so nobody should be working on it until a proposal is approved anyways.

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 8, 2016

Comment by Oliver Jones (JIRA)

Just being able to typealias generic types to rename them would be a bonus.

Eg, This is currently not possible:

class Person<T> {}

typealias LaPersonne = Person

Sometimes for clarity it is desirable to rename a type in a more specific local context and at the moment it doesn't appear to be possible to do with generic types without specialising those types.

@lilyball
Copy link
Mannequin Author

lilyball mannequin commented Jan 8, 2016

orj (JIRA User) The ideal way to handle that is to say

typealias LaPersonne<T> = Person<T>

If we didn't want to support generic parameters on typealiases then I'd say your typealias LaPersonne = Person should be made to work, but since we do want to support this, we shouldn't be hiding type parameters like that.

@slavapestov
Copy link
Member

This is implemented in Swift 3.0.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation improvement
Projects
None yet
Development

No branches or pull requests

3 participants