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 checks for 'late' initialized finals in dartdoc and clean up #2069

Merged
merged 1 commit into from
Nov 13, 2019

Conversation

jcollins-g
Copy link
Contributor

This lays groundwork for NNBD work in dartdoc. Basically this tests that switching on nnbd is possible and we generate reasonable output for a trivial case.

Screenshot:

Screen Shot 2019-11-13 at 11 52 58 AM

@googlebot googlebot added the cla: yes Google CLA check succeeded. label Nov 13, 2019
Field b = c.allFields.firstWhere((f) => f.name == 'b');
Field cField = c.allFields.firstWhere((f) => f.name == 'cField');
Field dField = c.allFields.firstWhere((f) => f.name == 'dField');
// If nnbd isn't enabled, fields named 'late' come back from the analyzer.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it useful to test for late when it is invalid to use?
I expected to see a NNBD enabled test, with late displayed as a modifier.

Copy link
Member

Choose a reason for hiding this comment

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

I this the test is what you expected, and that this is just ensuring that the library was analyzed correctly as being opted in. The comment indicates what analyzer would have produced if NNBD were not enabled, and hence what's being tested for.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think the late initialization of a field matters enough to mention it from the perspective of the API of a class -- though even as I say that I'm starting to wonder if that's true. I think it would usually be bad design to declare as a final field something you wanted users of the class to initialize externally, but I can think of some cases where people might desire that. My current thought is to tell users who do that to explicitly describe what's necessary in the doc for the field.

Field b = c.allFields.firstWhere((f) => f.name == 'b');
Field cField = c.allFields.firstWhere((f) => f.name == 'cField');
Field dField = c.allFields.firstWhere((f) => f.name == 'dField');
// If nnbd isn't enabled, fields named 'late' come back from the analyzer.
Copy link
Member

Choose a reason for hiding this comment

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

I this the test is what you expected, and that this is just ensuring that the library was analyzed correctly as being opted in. The comment indicates what analyzer would have produced if NNBD were not enabled, and hence what's being tested for.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 93.857% when pulling b987a28 on nnbd_initial into 4995e7e on master.

@jcollins-g jcollins-g merged commit 9263f70 into master Nov 13, 2019
@jcollins-g jcollins-g deleted the nnbd_initial branch November 13, 2019 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants