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

[Concept] abstract enums #10098

Closed
AdamSpeight2008 opened this issue Mar 25, 2016 · 1 comment
Closed

[Concept] abstract enums #10098

AdamSpeight2008 opened this issue Mar 25, 2016 · 1 comment
Labels
Area-Language Design Resolution-Duplicate The described behavior is tracked in another issue

Comments

@AdamSpeight2008
Copy link
Contributor

abstract enums

abstract enum E : int
{
  None = 0;
}

abstract enum E' : E
{
  None = 0, // Error: Already defined
  One  = 1
}

sealed enum E'' : E
{
  None = 2, // Error: Already defined
  One  = 1, // Error: Already defined
  Two  = 2
}

Inherting from a sealed enum

sealed enum F : E'' // Error: (E'') is sealed. Hence can not be inherited
{
 ...
} 

Generic Constraints
The CLR does allow constrained generics based on enums, just that it isn't (yet) expressible in C# or VB.

Foo <T : {enum, E} >( T e )
{

}

Existing enum construct

enum Foo { ... }

would be equivalent to

sealed enum Foo { ... }

Casts
All casting between abstract enum and a inherited enum,or vis-versa, must be explicit.

@HaloFour
Copy link

Seems mostly like a dupe of #9120

@gafter gafter added the Resolution-Duplicate The described behavior is tracked in another issue label Mar 25, 2016
@gafter gafter closed this as completed Mar 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Language Design Resolution-Duplicate The described behavior is tracked in another issue
Projects
None yet
Development

No branches or pull requests

4 participants