-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Remove an unnecessary assert #129796
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
Remove an unnecessary assert #129796
Conversation
The type variable `T`, when used as an expression, will always be a `Type`. The type test `T is! List` is always true (as is `T is Type`). This expression will become a warning in the analyzer in some upcoming release of the Dart SDK. This `assert` was added in a PR which reapplied an earlier PR, however the earlier PR did not include this assert. I do not see any discussion indicating the intent of this assert. The impact of testing this `T` in any way is low - this is a private class so we can see all the uses and know that the only type bound to `T` is `Uri`. Avoid the upcoming diagnostic and remove the assert entirely. This maintains existing behavior but ignores the potential intent for the check.
|
If I had to guess at the intent, it could have been to prevent usage where the If we use diff --git a/packages/flutter_tools/lib/src/protocol_discovery.dart b/packages/flutter_tools/lib/src/protocol_discovery.dart
index 578052bfb7..84f983ea5f 100644
--- a/packages/flutter_tools/lib/src/protocol_discovery.dart
+++ b/packages/flutter_tools/lib/src/protocol_discovery.dart
@@ -167,13 +167,10 @@ class _BufferedStreamController<T> {
final StreamController<T> streamControllerInstance = StreamController<T>.broadcast();
streamControllerInstance.onListen = () {
for (final dynamic event in _events) {
- if (event is T) {
- streamControllerInstance.add(event);
+ if (event is AsyncError) {
+ streamControllerInstance.addError(event.error, event.stackTrace);
} else {
- streamControllerInstance.addError(
- (event as Iterable<dynamic>).first as Object,
- event.last as StackTrace,
- );
+ streamControllerInstance.add(event as T);
}
}
_events.clear();
@@ -198,7 +195,7 @@ class _BufferedStreamController<T> {
if (_streamController.hasListener) {
_streamController.addError(error, stackTrace);
} else {
- _events.add(<dynamic>[error, stackTrace]);
+ _events.add(AsyncError(error, stackTrace));
}
} |
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: 129796, Mergeability of pull request flutter/flutter/129796 could not be determined at time of merge.. |
flutter/flutter@ff838bc...aa5f4a2 2023-07-01 [email protected] Enable no_wildcard_variable_uses lint (flutter/flutter#129858) 2023-06-30 [email protected] mark packages-autoroller bringup again (flutter/flutter#129859) 2023-06-30 [email protected] Update `SwitchTheme` tests for M2/M3 (flutter/flutter#129811) 2023-06-30 [email protected] Change pub roller bot to push to flutter-pub-roller-bot/flutter.git (flutter/flutter#129844) 2023-06-30 [email protected] Fix NetworkImage causing spurious warning in tests (flutter/flutter#129537) 2023-06-30 [email protected] Roll Flutter Engine from 54b573e9c4e5 to e6b8292705a8 (4 revisions) (flutter/flutter#129852) 2023-06-30 [email protected] Upgrade integration tests to use AGP 7.3/Gradle 7.4 (flutter/flutter#129642) 2023-06-30 [email protected] Roll Packages from d4752c4 to 53ed5a0 (5 revisions) (flutter/flutter#129837) 2023-06-30 [email protected] Updated correct tasks for test ownership fix (flutter/flutter#129812) 2023-06-30 [email protected] Updated some golden image tests for M2/M3 (flutter/flutter#129794) 2023-06-30 [email protected] Remove an unnecessary assert (flutter/flutter#129796) 2023-06-30 [email protected] Update `Radio` tests for M2/M3 (flutter/flutter#129814) 2023-06-30 [email protected] Update `Switch` tests for M2/M3 (flutter/flutter#129810) 2023-06-30 [email protected] Roll Flutter Engine from 099a70ebbc60 to 54b573e9c4e5 (1 revision) (flutter/flutter#129821) 2023-06-30 [email protected] Update `SwitchListTile` tests for M2/M3 (flutter/flutter#129809) 2023-06-30 [email protected] Fix `NavigationDrawer` selected item has wrong icon color (flutter/flutter#129625) 2023-06-30 [email protected] Update basic_test.dart for M3 compliance (flutter/flutter#129714) 2023-06-30 [email protected] Roll Flutter Engine from d33343430f18 to 099a70ebbc60 (7 revisions) (flutter/flutter#129818) 2023-06-30 [email protected] Roll Flutter Engine from 68cc1a7971d5 to d33343430f18 (2 revisions) (flutter/flutter#129801) 2023-06-30 [email protected] Revert no-response to fork. (flutter/flutter#129775) 2023-06-30 [email protected] Make `DropdownMenu` be able to scroll to the highlighted item when searching. (flutter/flutter#129740) 2023-06-29 [email protected] Roll Flutter Engine from cd9ce66db14a to 68cc1a7971d5 (10 revisions) (flutter/flutter#129799) 2023-06-29 49699333+dependabot[bot]@users.noreply.github.com Bump actions/labeler from 4.1.0 to 4.2.0 (flutter/flutter#129797) 2023-06-29 [email protected] Roll Flutter Engine from eabb22900b44 to cd9ce66db14a (1 revision) (flutter/flutter#129756) 2023-06-29 [email protected] Remove `@NonNull` to avoid warning (flutter/flutter#129472) 2023-06-29 [email protected] Remove use of any (flutter/flutter#129793) 2023-06-29 [email protected] Prepare for utf8.encode() to return more precise Uint8List type (flutter/flutter#129769) 2023-06-29 [email protected] Deletes files that should be ignored (flutter/flutter#127984) 2023-06-29 [email protected] Fix flutter_plugins by rolling revision (flutter/flutter#129781) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
The type variable
T, when used as an expression, will always be aType. The type testT is! Listis always true (as isT is Type).This expression will become a warning in the analyzer in some upcoming
release of the Dart SDK.
This
assertwas added in a PR which reapplied an earlier PR, howeverthe earlier PR did not include this assert. I do not see any discussion
indicating the intent of this assert.
The impact of testing this
Tin any way is low - this is a privateclass so we can see all the uses and know that the only type bound to
TisUri. Avoid the upcoming diagnostic and remove the assertentirely. This maintains existing behavior but ignores the potential
intent for the check.