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

add super initializer example #3178

Merged
merged 2 commits into from
Jan 24, 2022
Merged

add super initializer example #3178

merged 2 commits into from
Jan 24, 2022

Conversation

pq
Copy link
Member

@pq pq commented Jan 24, 2022

See: #3131

/cc @bwilkerson

@coveralls
Copy link

coveralls commented Jan 24, 2022

Coverage Status

Coverage increased (+0.002%) to 94.253% when pulling 49e62bc on type_init_formals_super_docs into f04d3e0 on master.

Copy link
Member

@bwilkerson bwilkerson left a 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.

@@ -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,
Copy link
Member

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.

Copy link
Member Author

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,

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

@bwilkerson bwilkerson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That lgtm.

@pq pq merged commit dd094ef into master Jan 24, 2022
@pq pq deleted the type_init_formals_super_docs branch January 24, 2022 23:35
copybara-service bot pushed a commit to dart-lang/sdk that referenced this pull request Aug 23, 2023
* add super initializer example

* tweaks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants