-
Notifications
You must be signed in to change notification settings - Fork 205
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 rules about super and extension types to wildcard spec #3729
Conversation
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.
Added a few explanatory remarks.
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.
This looks great, thank you! And thank you for the explanatory commentary too, it was very helpful.
*The desugared meaning of a super parameter includes a reference to the | ||
parameter in the initializer list of the enclosing constructor declaration, | ||
but such references are not possible when the parameter name is a | ||
wildcard.* |
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.
This is a funny subtle point, but made sense once I thought about it some 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.
This is great! Thank you so much for updating the spec, Erik!
### Super parameters | ||
|
||
An occurrence of `super._` as a declaration of a formal parameter in a | ||
constructor is a compile-time error. |
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.
Can you also help me visualize this, and maybe the following below, by adding a little code snippet/example?
The words make sense, I just learn better with examples.
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.
Done. This brings out a slight inconvenience, by the way. I added a commentary paragraph about it.
@kallentu, we might want to delete the 20 lines just before 'Unused variable warnings', PTAL. |
I would be okay with that. It might be more confusing with that example haha, but thank you for writing it up. |
OK, done! |
This PR adds rules to the wildcards feature specification about super parameters of the form
super._
, and about representation declarations in extension types whose representation variable name is_
.In particular,
super._
is an error because super parameters that can't be referenced from the initializer list are inherently broken. In contrast,extension type E(int _) {}
is allowed: The representation variable name will be_
and the formal parameter will be inaccessible (which makes no difference at this time, but will matter if a more general primary constructors feature is introduced).