-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Prepare for NULLABLE_ARGUMENT_TO_NON_NULL_TYPE
#121321
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
Conversation
| && event.extensionRPC == extensionName) { | ||
| isolateEvents.cancel(); | ||
| extensionAdded.complete(event.isolate); | ||
| extensionAdded.complete(event.isolate!); |
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 we add && event.isolate != null to the if comparison on lines 935-936?
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.
or, maybe another conditional here? i'm not sure what to do here, but also not confident we won't hit a null check error here. @bkonyi WDYT?
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 should never be null for a ServiceExtensionAdded event.
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.
From what I know, if there is a null passed during runtime, an exception would be thrown. That's the main motivation for dart-lang/sdk#51367
So, the previous code never sent a 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.
We get a lot of TypeErrors at runtime :)
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.
However, this SGTM per Ben's comment
|
Per https://github.com/flutter/flutter/wiki/Tree-hygiene#tests, I think you'll either need to add tests or request an exemption (I think an exemption would be reasonable here, but it's ultimately not my call) |
|
I am under the impression that the exemption is not needed, as long as the bot doesn't ask for tests. Anyway, a test exemption was requested. |
Ahh, good point, you're right, my bad! |
christopherfujino
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.
LGTM
|
auto label is removed for flutter/flutter, pr: 121321, due to - Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead. |
|
auto label is removed for flutter/flutter, pr: 121321, due to Validations Fail. |
|
test-exempt: Analysis fix before landing the lint in Dart |
andrewkolos
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.
LGTM
| _dismissedBottomSheets.add(bottomSheet); | ||
| } | ||
| completer.complete(); | ||
| completer.complete(null as T); |
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.
Wait a minute, is this a safe cast to make?
cc @goderbauer
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 doesn't look right. Is it just hiding a typing error elsewhere?
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.
Please have a look at this particular dart-lang/sdk#51367 (comment) and dart-lang/sdk#51367 (comment)
The current Flutter usage is actually 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.
My understanding from reading those comments is that the old code is unsafe (and that there may soon be a warning about this). This change silences that warning, but the code still remains unsafe: There is no guarantee that T is actually nullable, so this may still throw at runtime.
So, instead of just making sure the warning doesn't show up, we should actually fix the unsafe code here.
|
auto label is removed for flutter/flutter, pr: 121321, due to This PR has not met approval requirements for merging. Changes were requested by {christopherfujino}, please make the needed changes and resubmit this PR.
|
|
auto label is removed for flutter/flutter, pr: 121321, due to - This pull request has changes requested by @christopherfujino. Please resolve those before re-applying the label. |
| final AnimationController controller = (transitionAnimationController ?? BottomSheet.createAnimationController(this))..forward(); | ||
| setState(() { | ||
| _currentBottomSheet = _buildBottomSheet<T>( | ||
| _currentBottomSheet = _buildBottomSheet( |
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 now guaranteed to return a PersistentBottomSheetController. Will that not cause trouble for the cast to PersistentBottomSheetController<T> below in line 2464 if T is not void?
TBH, I am not sure what T is supposed to represent here and unfortunately, it is not documented. However, we likely have to figure that out to fix the typing here. From looking at this briefly it seems like passing anything but void for T will cause trouble...
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.
Maybe you were supposed to be able to pass back a return value when closing the bottom sheet (and T was the type for that), but from the looks of it maybe that got never fully implemented?
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.
Sorry for late response.
The issue is that showBottomSheet expects a type T, and then the completer must return that a value of that type (if it is not void).
Yes, it seems that having T was meant, but never used.
I would think to either change the signature of showBottomSheet to not have a type (I guess this is a breaking change), or find a way to send a value if T is actually passed.
|
@asashour are you still interested in working on this PR? |
|
will wait one more week, pinged @asashour in the discord. |
|
Closing as stale, feel free to re-open if you choose to pick this up again @asashour |
#121318
This PR modifies the code in order not to trigger the incoming diagnostic.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.