-
Notifications
You must be signed in to change notification settings - Fork 6k
Migrate tools/licenses to null safety #35882
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
From PR triage: Adding the WIP label. |
|
I believe this is ready for a review. There is one test failure, but I'm a bit puzzled as I don't think I changed anything in the logic of And the test output actually looks legit; it's triggered by the file |
Looking at the goldens, it seems we used to do this one correctly, so something in this patch must have affected it... |
tools/licenses/lib/main.dart
Outdated
| final _RepositorySourceFile main = parent.getChildByName('turbojpeg.c') as _RepositorySourceFile; | ||
| final _RepositoryDirectory simd = parent.getChildByName('simd') as _RepositoryDirectory; | ||
| List<License>? get licenses { | ||
| if (_licenses == null && parent != null) { |
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 && parent != null should not be necessary
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.
I'm a bit puzzled why that works given parent is nullable. I guess there is an invariant that get isn't called when parent is null?
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.
yeah, the root case is special in various ways such that the code never gets called when parent is null.
This code was designed for a nullable world. I would write it quite differently now with null safety.
| bool hadMoreLines; | ||
| while (hadMoreLines = lines.moveNext() && lines.current.value.startsWith(prefix)) { | ||
| final String nextAuthor = lines.current.value.substring(prefix.length); | ||
| if (nextAuthor == '' || nextAuthor[0] == ' ' || nextAuthor[0] == '\t') { | ||
| throw 'unexpectedly ragged author list when looking for copyright'; | ||
| } | ||
| end = lines.current.end; | ||
| } | ||
| if (lines.current == null) { | ||
| if (!hadMoreLines) { |
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 wonder if this is somehow not 100% exactly semantically equivalent and is causing the bug you ran into
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 was missing a set of parenthesis :-)
- while (hadMoreLines = lines.moveNext() && lines.current.value.startsWith(prefix)) {
+ while ((hadMoreLines = lines.moveNext()) && lines.current.value.startsWith(prefix)) {
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.
aha, glad i pinned down the section if not the reason :-)
|
Test is now passing, but I need to update the goldens: |
bbcb909 to
5204911
Compare
|
Golden updated: |
Hixie
left a comment
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 PR reminds me that I have a big patch (which is going to conflict up the wazoo now, oops! oh well) that was waiting for https://dart-review.googlesource.com/c/sdk/+/250792 to get reviewed and landed, but I was trying to follow the non-Googler path to contributing to Dart and didn't figure out how to get a review and then forgot about it. |
|
test-exempt: code refactor with no semantic change |
Migrate
src/flutter/tools/licensesto null safety.Contributes to flutter/flutter#110020
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.