-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
While working in adding Iterable<E>.whereType<T> method to collection_methods_unrelated_type lint rule in 351781, I came across the following case, which caused some tests to fail because of the new warning:
info • The argument type 'DevFSFileContent' isn't related to 'Iterable<AssetBundleEntry>' • packages/flutter_tools/lib/src/commands/test.dart:613:67 • collection_methods_unrelated_type
I already investigated this one to see if my change produced a correct report, and I believe it did for this case.
In line 623 of the method below (you may need to scroll to see it), there's a mapping by type (i.e. entries.values.whereType<DevFSFileContent>()) which will always produce an empty Iterable since entries.values is Iterable<AssetBundleEntry> and that will never contain a DevFSFileContent:
flutter/packages/flutter_tools/lib/src/commands/test.dart
Lines 608 to 632 in dde76f4
| bool _needRebuild(Map<String, AssetBundleEntry> entries) { | |
| // TODO(andrewkolos): This logic might fail in the future if we change the | |
| // schema of the contents of the asset manifest file and the user does not | |
| // perform a `flutter clean` after upgrading. | |
| // See https://github.com/flutter/flutter/issues/128563. | |
| final File manifest = globals.fs.file(globals.fs.path.join('build', 'unit_test_assets', 'AssetManifest.bin')); | |
| if (!manifest.existsSync()) { | |
| return true; | |
| } | |
| final DateTime lastModified = manifest.lastModifiedSync(); | |
| final File pub = globals.fs.file('pubspec.yaml'); | |
| if (pub.lastModifiedSync().isAfter(lastModified)) { | |
| return true; | |
| } | |
| for (final DevFSFileContent entry in entries.values.whereType<DevFSFileContent>()) { | |
| // Calling isModified to access file stats first in order for isModifiedAfter | |
| // to work. | |
| if (entry.isModified && entry.isModifiedAfter(lastModified)) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| } |
I assume this part should be something like this if I am not mistaken:
for (final DevFSFileContent entry in entries.values.map((asset) => asset.content).whereType<DevFSFileContent>())