-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Describe scoping rules for extension declaration type parameters and receiver parameter #9229
base: main
Are you sure you want to change the base?
Conversation
@@ -50,6 +50,38 @@ receiver_parameter // add | |||
Extension declarations shall only be declared in non-generic, non-nested static classes. | |||
It is an error for a type to be named `extension`. | |||
|
|||
### Scoping rules | |||
|
|||
The type parameters and receiver parameter of an extension declaration are in scope within the body of the extension declaration. It is an error to refer to the receiver parameter from within a static member. It is an error for members to declare type parameters or parameters with the same name as a type parameter or receiver parameter of the extension declaration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (commit 9)
@@ -50,6 +50,38 @@ receiver_parameter // add | |||
Extension declarations shall only be declared in non-generic, non-nested static classes. | |||
It is an error for a type to be named `extension`. | |||
|
|||
### Scoping rules | |||
|
|||
The type parameters and receiver parameter of an extension declaration are in scope within the body of the extension declaration. It is an error to refer to the receiver parameter from within a static member. It is an error for members to declare type parameters or parameters with the same name as a type parameter or receiver parameter of the extension declaration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an error for members to declare type parameters or parameters with the same name as a type parameter or receiver parameter of the extension declaration.
I think it is worth mentioning that the same goes for local variables and local function declared directly by members (not inside lamndas or local functions)
…e parameters See dotnet/csharplang#9229 (commit 9)
…e parameters (#77704) See dotnet/csharplang#9229 (commit 9)
Based on LDM feedback, these are revised scoping rules for extension declarations.