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

Add more options for type parameters #2329

Open
guenth39 opened this issue Jul 5, 2022 · 3 comments
Open

Add more options for type parameters #2329

guenth39 opened this issue Jul 5, 2022 · 3 comments
Labels
feature Proposed language feature that solves one or more problems

Comments

@guenth39
Copy link

guenth39 commented Jul 5, 2022

It would be great to have more options for type parameters. Specifically, it would be helpful for me if you could specify multiple types with an or and if you could make the type parameter required.

Example:

class MyClass<T extends ClassA || ClassB> {}

class MyClass<required T> {}

// good
final a = MyClass<ClassA>();

// bad => linter says type parameter is required
final a = MyClass();
@guenth39 guenth39 added the feature Proposed language feature that solves one or more problems label Jul 5, 2022
@eernstg
Copy link
Member

eernstg commented Jul 5, 2022

A proposal specifically for union types in type parameter bounds (and nowhere else) might be useful. But if you're interested in union types in general, it's recommended that the discussion is kept in issues where that proposal is already being debated, in particular: #83.

@mateusfccp
Copy link
Contributor

mateusfccp commented Jul 5, 2022

it would be helpful for me if you could specify multiple types with an or [...]

This seems to be the same request as #83 (although the title says "sum type", the content of the issue talks about untagged union type, which is different) or #145. If this is the case, could we close this as a duplicate of one of this issues? If not, cold you elaborate on how your idea differs from #83 and #145?

it would be helpful for me [...] if you could make the type parameter required.

Seems to be related to #150, although it didn't propose any solution in language-level like you did... Maybe enabling stricter rules in the analysis_options.yaml file will suffice for you?

Edit: Sorry for repeating what @eernstg said, he was quicker than me hehe

@eernstg
Copy link
Member

eernstg commented Jul 5, 2022

But I had less detail. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Proposed language feature that solves one or more problems
Projects
None yet
Development

No branches or pull requests

3 participants