[Proposal] Type alias in class/interface declaration #2936
Unanswered
Orace
asked this question in
Language Ideas
Replies: 1 comment
-
An optional part of this proposal is that a type alias for the current class may be used for call to any constructor. class Test<T1, T2> as TSelf
{
public static TSelf Build() => new TSelf();
public static TSelf Build(int v) => new TSelf(v);
public static TSelf Build(string s) => new TSelf(s);
Test() {}
Test(int v) {}
Test(string s) {}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a proposal to add type aliases in class and interface declaration.
Example
Considering this scenario:
The goal of this proposal is to simplify the declaration of
IDataProvider
like this:-A type alias lifetime is limited to the class / interface in which it's declared
-A type alias is visible from inner class
-A type alias is not visible to herited / implementing class
-A type alias have the same constraints as a type parameter
-A type alias can't be used before its declaration
Example of valid use
Example of invalid use
-A type alias is not visible to herited / implementing class
-A type alias can't be used before its declaration
Beta Was this translation helpful? Give feedback.
All reactions