-
Notifications
You must be signed in to change notification settings - Fork 170
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 super initializer example #3178
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.
The example is fine, but I have a small concern with the wording. Your choice whether to change it before landing.
lib/src/rules/type_init_formals.dart
Outdated
@@ -16,8 +16,8 @@ From the [style guide](https://dart.dev/guides/language/effective-dart/style/): | |||
|
|||
**DON'T** type annotate initializing formals. | |||
|
|||
If a constructor parameter is using `this.x` to initialize a field, then the | |||
type of the parameter is understood to be the same type as the field. | |||
If a constructor parameter is using `this.x` or `super.x` to initialize a field, |
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.
Kind of a nit, but super.x
doesn't initialize a field, so this might be confusing.
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.
Ah, let's get it right.
How about:
If a constructor parameter is using `this.x` to initialize a field or `super.x` to forward to a super constructor,
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.
That sounds good for the first part. The "same type as the field" on the next line will also need to be updated. Once you do that it might be clearer if you just split it into two sentences, but I don't know for sure because I haven't tried writing it.
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.
I see your point. I gave it a shot in two sentences. PTAL.
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.
That lgtm.
* add super initializer example * tweaks
See: #3131
/cc @bwilkerson